Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Auto pause when ALSA device disappears? #1153

Open
Galicarnax opened this issue Jan 2, 2023 · 1 comment
Open

Auto pause when ALSA device disappears? #1153

Galicarnax opened this issue Jan 2, 2023 · 1 comment
Labels
blocked by: librespot Issues that are blocked by librespot's upstream bug A functionality or parts of a program that do not work as intended

Comments

@Galicarnax
Copy link

Galicarnax commented Jan 2, 2023

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

  1. Start spotifyd with ALSA backend and a single ALSA device
  2. Start playing
  3. Switch off ALSA device
  4. spotifdy crashes

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)
@Galicarnax Galicarnax added the bug A functionality or parts of a program that do not work as intended label Jan 2, 2023
@eladyn eladyn added crate update pending Denotes that the fix will be implemented in a future crate version and work has already started blocked by: librespot Issues that are blocked by librespot's upstream and removed crate update pending Denotes that the fix will be implemented in a future crate version and work has already started labels Jan 16, 2023
@eladyn
Copy link
Member

eladyn commented Jan 16, 2023

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. (librespot-org/librespot#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. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked by: librespot Issues that are blocked by librespot's upstream bug A functionality or parts of a program that do not work as intended
Projects
None yet
Development

No branches or pull requests

2 participants