ralph-irving / squeezelite

Lightweight headless squeezebox player for Lyrion Media Server
https://sourceforge.net/projects/lmsclients/files/squeezelite/
Other
375 stars 96 forks source link

Cannot play PGGB (WAV) files of 705 and 768kHz #191

Open PrinceJJPablo opened 9 months ago

PrinceJJPablo commented 9 months ago

Previously I used Marco's Squeezelite-R2 at 1.8.4 and playing PGGB files worked with no issues. Because of Fedora's rolling updates and other reasons I have decided to use this squeezelite version.

However after installing 1.9.9 I have noticed that PGGB files no longer play in this squeezelite version?

Info: PGGB 705kHz & PGGB 768kHz (WAV) Squeezelite version 1.9.9.1392 LMS version 8.3.1 Fedora 36 DAC max: PCM 768000 DSD 512

squeezelite.log after playing a normal WAV file (works) then playing a PGGB 705 file 16fs (plays but sound is extremely distorted):

/usr/bin/squeezelite -o hw:1,0 -n princeS40 -D :u32be -m 00:30:18:0B:EA:0C -s princeS40.local -a :::0 -r auto -M princeS40 -p 77 -R vE:26:1:36:96:104:33 -d all=debug -f /var/log/squeezelite/squeezelite.log 

[18:45:18.501434] stream_init:454 init stream
[18:45:18.501587] stream_init:455 streambuf size: 2097152
[18:45:18.512985] output_init_alsa:936 init output
[18:45:18.513036] output_init_alsa:975 requested alsa_buffer: 40 alsa_period: 4 format: any mmap: 0
[18:45:18.513068] output_init_common:360 outputbuf size: 28224000
[18:45:18.513150] output_init_common:384 idle timeout: 0
[18:45:18.520231] test_open:301 sample rate 1536000 not supported
[18:45:18.520253] test_open:301 sample rate 1411200 not supported
[18:45:18.520308] test_open:301 sample rate 32000 not supported
[18:45:18.520317] test_open:301 sample rate 24000 not supported
[18:45:18.520326] test_open:301 sample rate 22500 not supported
[18:45:18.520334] test_open:301 sample rate 16000 not supported
[18:45:18.520342] test_open:301 sample rate 12000 not supported
[18:45:18.520350] test_open:301 sample rate 11025 not supported
[18:45:18.520358] test_open:301 sample rate 8000 not supported
[18:45:18.520384] output_init_common:426 supported rates: 768000 705600 384000 352800 192000 176400 96000 88200 48000 44100 
[18:45:18.533295] output_init_alsa:1002 memory locked
[18:45:18.533332] output_init_alsa:1008 glibc detected using mallopt
[18:45:18.533545] output_init_alsa:1028 set output sched fifo rt: 77
[18:45:18.533559] decode_init:153 init decode
[18:45:18.533575] output_thread:685 open output device: hw:1,0
[18:45:18.533689] alsa_open:354 opening device at: 44100
[18:45:18.533604] register_dsd:908 using dsd to decode dsf,dff
[18:45:18.533732] register_vorbis:385 using vorbis to decode ogg
[18:45:18.533740] register_opus:328 using opus to decode ops
[18:45:18.533746] register_flac:336 using flac to decode ogf,flc
[18:45:18.533753] register_pcm:483 using pcm to decode aif,pcm
[18:45:18.533761] register_mad:423 using mad to decode mp3
[18:45:18.533768] decode_init:194 include codecs:  exclude codecs: 
[18:45:18.533878] resample_init:360 resampling sync recipe: 0x06, flags: 0x26, scale: 0.89, precision: 36.0, passband_end: 0.96000, stopband_begin: 1.04000, phase_response: 33.0
[18:45:18.533885] alsa_open:425 opened device hw:1,0 using format: S32_LE sample rate: 44100 mmap: 0
[18:45:18.533942] alsa_open:516 buffer: 40 period: 4 -> buffer size: 1764 period size: 441
[18:45:18.935269] slimproto:898 connecting to 127.0.0.1:3483
[18:45:18.935571] slimproto:937 connected
[18:45:18.935691] slimproto:948 local player
[18:45:18.935724] sendHELO:148 mac: 00:30:18:0b:ea:0c
[18:45:18.935753] sendHELO:150 cap: CanHTTPS=1,Model=squeezelite,AccuratePlayPoints=1,HasDigitalOut=1,HasPolarityInversion=1,Balance=1,Firmware=v1.9.9-1392,ModelName=princeS40,MaxSampleRate=768000,dsf,dff,ogg,ops,ogf,flc,aif,pcm,mp3,loc
[18:45:18.937417] process:528 strm
[18:45:18.937486] process_strm:280 strm command q
[18:45:18.937512] decode_flush:236 decode flush
[18:45:18.937534] output_flush:439 flush output buffer
[18:45:18.937557] sendSTAT:195 STAT: STMf
[18:45:18.937722] process:528 strm
[18:45:18.937765] process_strm:280 strm command q
[18:45:18.937806] decode_flush:236 decode flush
[18:45:18.937871] output_flush:439 flush output buffer
[18:45:18.937901] sendSTAT:195 STAT: STMf
[18:45:18.937994] process:528 setd
[18:45:18.938027] sendSETDName:254 set playername: princeS40
[18:45:18.938106] process:528 setd
[18:45:18.938398] process:528 aude
[18:45:18.938465] process_aude:422 enable spdif: 1 dac: 1
[18:45:18.938565] process:528 audg
[18:45:18.938634] process_audg:440 audg gainL: 3840 gainR: 3840 adjust: 0
[18:45:18.938677] set_volume:233 setting internal gain left: 65536 right: 65536
[18:45:19.000548] process:528 strm
[18:45:19.000679] process_strm:280 strm command t
[18:45:19.000718] sendSTAT:195 STAT: STMt
[18:45:23.000642] process:528 strm
[18:45:23.000761] process_strm:280 strm command t
[18:45:23.000799] sendSTAT:195 STAT: STMt
[18:45:25.550111] process:528 strm
[18:45:25.550200] process_strm:280 strm command q
[18:45:25.550229] decode_flush:236 decode flush
[18:45:25.550254] output_flush:439 flush output buffer
[18:45:25.550280] sendSTAT:195 STAT: STMf
[18:45:25.576092] process:528 audg
[18:45:25.576124] process_audg:440 audg gainL: 3840 gainR: 3840 adjust: 0
[18:45:25.576134] set_volume:233 setting internal gain left: 65536 right: 65536
[18:45:25.576407] process:528 strm
[18:45:25.576427] process_strm:280 strm command s
[18:45:25.576436] process_strm:349 strm s autostart: 1 transition period: 10 transition type: 0 codec: p
[18:45:25.576444] sendSTAT:195 STAT: STMf
[18:45:25.576463] codec_open:264 codec open: 'p'
[18:45:25.576473] pcm_open:447 pcm size: 3 rate: 192000 chan: 2 bigendian: 0
[18:45:25.576500] connect_socket:164 connecting to 127.0.0.1:9000
[18:45:25.576558] stream_sock:600 header: GET /stream.mp3?player=00:30:18:0b:ea:0c HTTP/1.0

[18:45:25.576570] sendSTAT:195 STAT: STMc
[18:45:25.576581] process_strm:384 set fade mode: 0, channels: 0, invert: 0
[18:45:25.576609] process:528 audg
[18:45:25.576623] process_audg:440 audg gainL: 3840 gainR: 3840 adjust: 0
[18:45:25.576631] set_volume:233 setting internal gain left: 65536 right: 65536
[18:45:25.741540] stream_thread:331 headers: len: 490
HTTP/1.1 200 OK
Server: Logitech Media Server (8.3.1 - 1676361197)
Connection: close
Content-Type: audio/L16
Set-Cookie: Squeezebox-albumView=; path=/
Set-Cookie: Squeezebox-expandPlayerControl=true; path=/
Set-Cookie: Squeezebox-expanded-MY_MUSIC=0; path=/
Set-Cookie: Squeezebox-expanded-FAVORITES=0; path=/
Set-Cookie: Squeezebox-expanded-PLUGINS=0; path=/
Set-Cookie: Squeezebox-expanded-PLUGIN_MY_APPS_MODULE_NAME=0; path=/
Set-Cookie: Squeezebox-expanded-RADIO=0; path=/

[18:45:25.741764] sendRESP:226 RESP
[18:45:25.747236] pcm_decode:214 setting track_start
[18:45:25.747382] resample_newstream:232 disable resampling - rates match
[18:45:25.747398] process_newstream:124 processing: inactive
[18:45:25.757465] _output_frames:65 start buffer frames: 76458
[18:45:25.757506] _output_frames:153 track start sample rate: 192000 replay_gain: 0
[18:45:25.757523] sendSTAT:195 STAT: STMs
[18:45:25.757560] sendSTAT:195 STAT: STMt
[18:45:25.767576] output_thread:685 open output device: hw:1,0
[18:45:25.870421] alsa_open:354 opening device at: 192000
[18:45:25.871038] alsa_open:425 opened device hw:1,0 using format: S32_LE sample rate: 192000 mmap: 0
[18:45:25.871144] alsa_open:516 buffer: 40 period: 4 -> buffer size: 7680 period size: 1920
[18:45:26.757715] sendSTAT:195 STAT: STMt
[18:45:27.000685] process:528 strm
[18:45:27.000778] process_strm:280 strm command t
[18:45:27.000809] sendSTAT:195 STAT: STMt
[18:45:28.001752] sendSTAT:195 STAT: STMt
[18:45:29.002688] sendSTAT:195 STAT: STMt
[18:45:30.003661] sendSTAT:195 STAT: STMt
[18:45:31.000746] process:528 strm
[18:45:31.000852] process_strm:280 strm command t
[18:45:31.000935] sendSTAT:195 STAT: STMt
[18:45:32.001712] sendSTAT:195 STAT: STMt
[18:45:33.002725] sendSTAT:195 STAT: STMt
[18:45:34.003662] sendSTAT:195 STAT: STMt
[18:45:35.004709] sendSTAT:195 STAT: STMt
[18:45:35.018732] process:528 strm
[18:45:35.018802] process_strm:280 strm command t
[18:45:35.018828] sendSTAT:195 STAT: STMt
[18:45:36.019655] sendSTAT:195 STAT: STMt
[18:45:37.020647] sendSTAT:195 STAT: STMt
[18:45:38.001469] process:528 strm
[18:45:38.001500] process_strm:280 strm command q
[18:45:38.001508] decode_flush:236 decode flush
[18:45:38.001515] output_flush:439 flush output buffer
[18:45:38.001687] sendSTAT:195 STAT: STMf
[18:45:38.002116] process:528 strm
[18:45:38.002136] process_strm:280 strm command q
[18:45:38.002144] decode_flush:236 decode flush
[18:45:38.002151] output_flush:439 flush output buffer
[18:45:38.002158] sendSTAT:195 STAT: STMf
[18:45:38.025574] process:528 audg
[18:45:38.025702] process_audg:440 audg gainL: 3840 gainR: 3840 adjust: 0
[18:45:38.025730] set_volume:233 setting internal gain left: 65536 right: 65536
[18:45:38.026471] process:528 strm
[18:45:38.026530] process_strm:280 strm command s
[18:45:38.026557] process_strm:349 strm s autostart: 1 transition period: 10 transition type: 0 codec: p
[18:45:38.026580] sendSTAT:195 STAT: STMf
[18:45:38.026678] codec_open:264 codec open: 'p'
[18:45:38.026710] pcm_open:447 pcm size: 4 rate: 44100 chan: 2 bigendian: 0
[18:45:38.026779] connect_socket:164 connecting to 127.0.0.1:9000
[18:45:38.026936] stream_sock:600 header: GET /stream.mp3?player=00:30:18:0b:ea:0c HTTP/1.0

[18:45:38.026973] sendSTAT:195 STAT: STMc
[18:45:38.027005] process_strm:384 set fade mode: 0, channels: 0, invert: 0
[18:45:38.027049] process:528 audg
[18:45:38.027072] process_audg:440 audg gainL: 3840 gainR: 3840 adjust: 0
[18:45:38.027094] set_volume:233 setting internal gain left: 65536 right: 65536
[18:45:38.104878] stream_thread:331 headers: len: 490
HTTP/1.1 200 OK
Server: Logitech Media Server (8.3.1 - 1676361197)
Connection: close
Content-Type: audio/L16
Set-Cookie: Squeezebox-albumView=; path=/
Set-Cookie: Squeezebox-expandPlayerControl=true; path=/
Set-Cookie: Squeezebox-expanded-MY_MUSIC=0; path=/
Set-Cookie: Squeezebox-expanded-FAVORITES=0; path=/
Set-Cookie: Squeezebox-expanded-PLUGINS=0; path=/
Set-Cookie: Squeezebox-expanded-PLUGIN_MY_APPS_MODULE_NAME=0; path=/
Set-Cookie: Squeezebox-expanded-RADIO=0; path=/

[18:45:38.104977] sendRESP:226 RESP
[18:45:38.174937] pcm_decode:214 setting track_start
[18:45:38.174991] resample_newstream:232 disable resampling - rates match
[18:45:38.175005] process_newstream:124 processing: inactive
[18:45:38.181992] _output_frames:65 start buffer frames: 262143
[18:45:38.182062] _output_frames:153 track start sample rate: 44100 replay_gain: 0
[18:45:38.182096] sendSTAT:195 STAT: STMs
[18:45:38.182194] sendSTAT:195 STAT: STMt
[18:45:38.192115] output_thread:685 open output device: hw:1,0
[18:45:38.294407] alsa_open:354 opening device at: 44100
[18:45:38.294882] alsa_open:425 opened device hw:1,0 using format: S32_LE sample rate: 44100 mmap: 0
[18:45:38.294965] alsa_open:516 buffer: 40 period: 4 -> buffer size: 1764 period size: 441
[18:45:39.183370] sendSTAT:195 STAT: STMt
[18:45:40.000519] process:528 strm
[18:45:40.000663] process_strm:280 strm command t
[18:45:40.000718] sendSTAT:195 STAT: STMt
[18:45:41.001703] sendSTAT:195 STAT: STMt
[18:45:42.002649] sendSTAT:195 STAT: STMt
[18:45:43.003697] sendSTAT:195 STAT: STMt
[18:45:44.000574] process:528 strm
[18:45:44.000763] process_strm:280 strm command t
[18:45:44.000878] sendSTAT:195 STAT: STMt
[18:45:45.001679] sendSTAT:195 STAT: STMt
[18:45:46.002647] sendSTAT:195 STAT: STMt
[18:45:47.003656] sendSTAT:195 STAT: STMt
[18:45:48.000545] process:528 strm
[18:45:48.000667] process_strm:280 strm command t
[18:45:48.000704] sendSTAT:195 STAT: STMt
[18:45:49.001732] sendSTAT:195 STAT: STMt
[18:45:50.002701] sendSTAT:195 STAT: STMt
[18:45:51.003689] sendSTAT:195 STAT: STMt
[18:45:52.000553] process:528 strm
[18:45:52.000739] process_strm:280 strm command t
[18:45:52.000795] sendSTAT:195 STAT: STMt
[18:45:52.796197] sendSTAT:195 STAT: STMt
[18:45:52.796421] process:528 strm
[18:45:52.796480] process_strm:280 strm command q
[18:45:52.796571] decode_flush:236 decode flush
[18:45:52.796684] output_flush:439 flush output buffer
[18:45:52.798086] sendSTAT:195 STAT: STMf
[18:45:56.000742] process:528 strm
[18:45:56.000858] process_strm:280 strm command t
[18:45:56.000949] sendSTAT:195 STAT: STMt
[18:46:00.000724] process:528 strm
[18:46:00.000832] process_strm:280 strm command t
[18:46:00.000868] sendSTAT:195 STAT: STMt

Anything I can check to try to fix this?

Already tried the following:

  1. Adding -W option on squeezelite for server side upsampling

  2. PGGB file is not corrupted, testing on a fedora 30 (note this is a lower version) system with squeezelite-R2 1.8.4 on the same LMS version and same DAC plays the PGGB file with no issue.

  3. Update fedora? In the future. Right now I need to use this version of fedora for testing.

nvitorino commented 9 months ago

Hi,

Indeed it would be great for squeezelite to support this directly but at the moment the way to do this is to use C-3PO plugin. If you install this, C-3PO with convert the WAV with ffmpeg which renders it in a format compatible with Squeezelite (with -W flag). This will allow you to play the PGGB tracks. Having said that, there are still WAV tracks than can be problematic, we're trying to look into this and eventually propose a pull request with a solution.

PrinceJJPablo commented 9 months ago

Thanks for the response @nvitorino,

I have confirmed with my system that doing the above allows for PGGB playback:

  1. Set -W flag in squeezelite

  2. Install C3PO and setup/configure to convert WAV through ffmpeg (Ensure you configure this correctly)

However I noticed this caused the following issues (Unsure if this is caused by external factors):

DSD Files would not play properly after relaunching squeezelite.

To fix:

  1. Power down the machine fully and relaunch squeezelite (same settings) and it seemed this fixed the issue and the machine can play DSD files and PGGB files - I will continue to investigate why this is.

In the future it would be nice to have Native PGGB support : )

Shall I leave this ticket open?

Technically not fixed for squeezelite and requires C3PO plugin from LMS to patch the issue?

nvitorino commented 8 months ago

Thanks for the response @nvitorino,

I have confirmed with my system that doing the above allows for PGGB playback:

  1. Set -W flag in squeezelite
  2. Install C3PO and setup/configure to convert WAV through ffmpeg (Ensure you configure this correctly)

However I noticed this caused the following issues (Unsure if this is caused by external factors):

DSD Files would not play properly after relaunching squeezelite.

To fix:

  1. Power down the machine fully and relaunch squeezelite (same settings) and it seemed this fixed the issue and the machine can play DSD files and PGGB files - I will continue to investigate why this is.

In the future it would be nice to have Native PGGB support : )

Shall I leave this ticket open?

Technically not fixed for squeezelite and requires C3PO plugin from LMS to patch the issue?

The issue I have found is that with this solution some WAV files that played correctly now end prematurely a few seconds before the end of the file. Also, -W affects also AIFF which means these myse be converted by C3PO (ffmpeg) as well. Using C3PO also means all players would have to use the -W flag which then causes issues with hardware players - we would have to use custom-convert rules specific for some players, which is a bit of a pain...

From what I read here, the -W does need to exist due to the behaviour of LMS and squeezelite can't do much about this. But at least it would be great if there's no premature end of some WAV files which is very annoying. @ralph-irving - if you'd like some files to test this please PM me and I'll be happy to follow this up.

nvitorino commented 7 months ago

From some more additional testing, I can circumvent the issue of having the files prematurely cutoff by increasing the streaming buffer significantly, in fact proportional to the size of the files. It looks like the streaming buffer needs to as large or close to the size of the file itself. I've tried setting the streaming buffer to 1.5GB and that worked on every file I've tried. However, the large buffers can have other implications as well as the fact some devices will be lacking the RAM to have such large buffers. I'm not sure if this is somehow related to Squeezelite or the way ffmpeg is doing the conversion.

In summary:

Ideally Squeezelite would support directly 32bit floating point WAV files. This would avoid using ffmpeg to convert the headers and having to use large buffers due to ffmpeg. I do understand that, in the global scheme of things, there are few users playing 32bit floating point WAV files as these tend to come directly from studios. @ralph-irving , would you be able to point out where in the code we should look at this and we might be able to give this a go and propose a pull request?