ralph-irving / squeezelite

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

pCP won't start when DAC is powered off #173

Open marcgarciamarti opened 2 years ago

marcgarciamarti commented 2 years ago

Hello!

I have an external DAC but this behaviour has been observed with both my external DAC (Topping E50) and with the DAC which is built into my Cambridge CXA61.

If the RPI3B+ where pCP is deployed is off (aka, power cable disconnected from the wall), and I power it on, pCP boots up but it won't find the audio device that I have set up in my preferences (because the DAC is not detected). I guess it has to do with how Linux and ALSA are designed, but I don't know.

The only solution I've found is:

What would I expect? I would expect for pCP to be able to come up nicely, and continuously ping for the DAC. Once the DAC comes back on, I would expect for pCP to detect the change and do the needed to prepare itself for music playback.

What have I tried? I applied the recommendations found here: https://forums.slimdevices.com/showthread.php?109934-LMS-could-not-reestablish-any-USB-connection-after-USB-Dac-is-disconnected&p=930865&viewfull=1#post930865 I also followed this article: https://docs.picoreplayer.org/projects/autostart-squeezelite-from-usb-dac/

but none of these two suggestions have managed to address my problem

I hope you guys can give me a hand. Thank you!!

marcgarciamarti commented 1 year ago

Hello @ralph-irving ! I wonder if you ever had the chance to check my writeup. Do you need any additional clarification? is there any additional input that I could provide? thanks!

shaffenmeister commented 1 year ago

@marcgarciamarti, that does seem to be a squeezelite but a piCorePlayer configuration issue. I have observed similar issues when squeezelite was started before the system detected the sound card. I think it would be sensible to check back with a pCP forum.

Supertramp1969 commented 1 year ago

In actual fact pCP starts, but not Squeezelite. I’m having the same with my Preamp Classé CP-800 with built in USB DAC. When the unit is in standby, it is not seen by Squeezelite. This is not a problem though. Just make sure that when you boot your pCP or when you start Squeezelite, your DAC is on. in the Squeezelite settings, put a 1 behind Close Output Setting.

This means that Squeezelite will close its output 1 second after you stop listening to your music. When you then switch off the DAC, Squeezelite will not notice and keeps running until your next listening session… assuming you leave pCP always on, like I do.

Using it like this for ages and works fantastic.

Good luck.

sandeen commented 9 months ago

Just a note, Klipsch "The One Plus" (and presumably the "The Three Plus") has a USB DAC which disconnects when the speaker's input is switched away from USB (to bluetooth or aux, etc.) This means squeezelite won't start properly unless the speaker is on and switched to USB input. This confused me until I did some digging and found issues like this.

It'd be nice if Squeezelite could start up without the device present, but for now I'll try the script to autostart squeezelite as described here.

ralph-irving commented 9 months ago

Squeezelite will start with the dac off if you use the name of the device with the -o option not the index number and you specify the supported sample rates using -r on the command line.

For example with device unplugged.

$ squeezelite -o hw:CARD=DAC -d all=info

[16:22:57.613287] stream_init:756 init stream
[16:22:57.619317] output_init_alsa:936 init output
[16:22:57.619419] output_init_alsa:976 requested alsa_buffer: 40 alsa_period: 4 format: any mmap: 1
[16:22:57.628196] ALSA _snd_pcm_hw_open:1401 Invalid value for card
[16:22:57.628249] test_open:281 playback open error: No such device
[16:22:57.628264] output_init_common:401 unable to open output device: hw:CARD=DAC

$ squeezelite -o hw:CARD=DAC -r 192000 -d all=info

[16:26:44.144645] stream_init:756 init stream
[16:26:44.151467] output_init_alsa:936 init output
[16:26:44.151550] output_init_alsa:976 requested alsa_buffer: 40 alsa_period: 4 format: any mmap: 1
[16:26:44.151660] output_init_common:426 supported rates: 192000 176400 96000 88200 48000 44100 32000 24000 22500 16000 12000 11025 8000 
[16:26:44.158459] output_init_alsa:1002 memory locked
[16:26:44.158560] output_init_alsa:1008 glibc detected using mallopt
[16:26:44.158864] decode_init:153 init decode
[16:26:44.158887] register_alac:549 using alac to decode alc
[16:26:44.158900] register_faad:663 using faad to decode aac
[16:26:44.158911] register_vorbis:378 using vorbis to decode ogg
[16:26:44.158919] register_opus:324 using opus to decode ops
[16:26:44.158930] register_flac:365 using flac to decode ogf,flc
[16:26:44.158941] register_pcm:483 using pcm to decode aif,pcm
[16:26:44.158964] register_mad:423 using mad to decode mp3
[16:26:44.159216] discover_server:800 sending discovery
[16:26:44.159763] discover_server:811 got response from: 192.168.1.1:3483
[16:26:44.159798] slimproto:903 connecting to 192.168.1.1:3483
[16:26:44.160179] slimproto:942 connected
[16:26:44.160211] sendHELO:150 cap: CanHTTPS=1,Model=squeezelite,AccuratePlayPoints=1,HasDigitalOut=1,HasPolarityInversion=1,Balance=1,Firmware=v2.0.0-1466,ModelName=SqueezeLite,MaxSampleRate=192000,alc,aac,ogg,ops,ogf,flc,aif,pcm,mp3
[16:26:44.161359] decode_flush:244 decode flush
[16:26:44.161378] output_flush:439 flush output buffer (full)
Supertramp1969 commented 9 months ago

Oh wow. Using the -r is even better in my case than using the -C option. Glad to have been included in this exchange. Keep up the good work. Many thanks and take care !!

Edit: The -C option remains necessary in case the DAC is switched off before the RPi, in which case Squeezelite keeps running but loses the connection with the DAC. The next time the DAC is switched on again Squeezelite needs to be restarted.