spotifyd
spotifyd copied to clipboard
Auto pause when ALSA device disappears?
Description
Using spotifyd on RPi4 with ALSA as backend and USB DAC as output. No sound servers used. Everything works fine, except that when the USB DAC is switched off, spotifyd crashes, with logs like this:
The application panicked (crashed).
Message: called `Result::unwrap()` on an `Err` value: Error("snd_pcm_recover", Sys(ENODEV))
Location: /build/.cargo/registry/src/github.com-1ecc6299db9ec823/librespot-playback-0.2.0/src/audio_backend/alsa.rs:164
Backtrace omitted.
Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
The application panicked (crashed).
Message: called `Option::unwrap()` on a `None` value
Location: src/main_loop.rs:194
Backtrace omitted.
Run with RUST_BACKTRACE=1 environment variable to display it.
Run with RUST_BACKTRACE=full to include source snippets.
Player thread panicked!
Is it possible to make a configuration such that when ALSA device disappears, spotifyd makes a pause instead of crash? E.g., this is the standard behaviour of the mpd player. As far as I can tell, both mpd and spotifyd use libasound, so probably it is possible to implement something like catching the event/exception from libasound when ALSA device disappears.
NB: If ALSA device is switched off when spotifyd is paused, it does not crash, until I ask it to play.
To Reproduce
- Start
spotifydwith ALSA backend and a single ALSA device - Start playing
- Switch off ALSA device
spotifdycrashes
Expected behavior Pause instead of crash
Compilation flags Installed from Arch Linux community repo (Arch Linux ARM port)
Versions (please complete the following information):
- OS: Arch Linux ARM
- Spotifyd: 0.3.4
- cargo: have no idea (not a rustacean)
Thank you for the report. As we don't implement that backend logic ourselves, we're basically blocked by librespot on that. Fortunately, there has been some work going on in that direction. (https://github.com/librespot-org/librespot/issues/1057) If you can't wait for these improvements hitting a spotifyd (which may very well take a long time, unfortunately), you could use librespot from the development branch directly and see if that fixes your problem.
Otherwise, you'll need to wait for that fix being released by librespot and spotifyd catching up. ;)