[GH-ISSUE #1478] librespot crashes if alsa device is temporary not available #664

Closed
opened 2026-02-27 19:31:50 +03:00 by kerem · 4 comments
Owner

Originally created by @ers4691 on GitHub (Mar 22, 2025).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/1478

Description

Have a USB DAC as an alsa device, librespot crashes, if the USB DAC is switched of.

Version

librespot 0.6.0 383a6f6 (Built on 2025-03-02, Build ID: fJnuxGP3, Profile: release)
librespot is running inside a container.

How to reproduce

Steps to reproduce the behavior in librespot e.g.

  1. Launch librespot with an alsa device, currently not available
  2. See some error/problem

Log

https://pastebin.com/xemUBTUq

Host (what you are running librespot on):

  • OS: Linux
  • Platform: Docker giof71/librespot

Additional context

Originally created by @ers4691 on GitHub (Mar 22, 2025). Original GitHub issue: https://github.com/librespot-org/librespot/issues/1478 ### Description Have a USB DAC as an alsa device, librespot crashes, if the USB DAC is switched of. ### Version librespot 0.6.0 383a6f6 (Built on 2025-03-02, Build ID: fJnuxGP3, Profile: release) librespot is running inside a container. ### How to reproduce Steps to reproduce the behavior in *librespot* e.g. 1. Launch `librespot` with an alsa device, currently not available 4. See some error/problem ### Log https://pastebin.com/xemUBTUq ### Host (what you are running `librespot` on): - OS: Linux - Platform: Docker giof71/librespot ### Additional context
kerem 2026-02-27 19:31:50 +03:00
  • closed this issue
  • added the
    bug
    label
Author
Owner

@kingosticks commented on GitHub (Mar 22, 2025):

Do I understand correctly? You launch librespot and specify an audio device that doesn't currently exist (because you already switched it off)? What do you want librespot to do in this case? Exit more gracefully rather than crashing?? Or magically pick some other device to use, despite you explicitly specifying one? The latter makes no sense to me.

<!-- gh-comment-id:2745205737 --> @kingosticks commented on GitHub (Mar 22, 2025): Do I understand correctly? You launch librespot and specify an audio device that doesn't currently exist (because you already switched it off)? What do you want librespot to do in this case? Exit more gracefully rather than crashing?? Or magically pick some other device to use, despite you explicitly specifying one? The latter makes no sense to me.
Author
Owner

@photovoltex commented on GitHub (Mar 22, 2025):

I think a graceful exit would be expected behavior, rather then a panic. It's technically not a bad behavior in itself, as we would stop the application anyways. But it's probably still considered a hard crash, especially when you build librespot optimized and remove the panic! handling.

<!-- gh-comment-id:2745448641 --> @photovoltex commented on GitHub (Mar 22, 2025): I think a graceful exit would be expected behavior, rather then a panic. It's technically not a bad behavior in itself, as we would stop the application anyways. But it's probably still considered a hard crash, especially when you build librespot optimized and remove the `panic!` handling.
Author
Owner

@ers4691 commented on GitHub (Mar 22, 2025):

Actually, I expect the same thing that mpd is doing in this case.
Nothing at all when starting up, as nobody is accessing the ALSA device. I would only expect a ‘Device not found’ error when a client connects to librespot if the USB device is not switched on.
If the device is switched on in the meantime, the music should of course be playing on it.

I think this is a completely normal use-case for USB DACs if you don't want to switch everything on all the time.

Since the whole thing runs in a Docker environment, I have exactly the desired behaviour. The container is permanently restarted until the USB ALSA device is switched on. However, I don't find this particularly elegant.

An alternative would probably be to connect a pulse-audio in between....

<!-- gh-comment-id:2745540693 --> @ers4691 commented on GitHub (Mar 22, 2025): Actually, I expect the same thing that mpd is doing in this case. Nothing at all when starting up, as nobody is accessing the ALSA device. I would only expect a ‘Device not found’ error when a client connects to librespot if the USB device is not switched on. If the device is switched on in the meantime, the music should of course be playing on it. I think this is a completely normal use-case for USB DACs if you don't want to switch everything on all the time. Since the whole thing runs in a Docker environment, I have exactly the desired behaviour. The container is permanently restarted until the USB ALSA device is switched on. However, I don't find this particularly elegant. An alternative would probably be to connect a pulse-audio in between....
Author
Owner

@kingosticks commented on GitHub (Mar 23, 2025):

Ok, thanks for explaining. In the case of an internal soundcard it's reasonable to expect a fail-fast style behaviour but I think you can argue it either way. However, I see how the alternate behaviour is more flexible so seems a valid improvement for someone to take on.

<!-- gh-comment-id:2745923659 --> @kingosticks commented on GitHub (Mar 23, 2025): Ok, thanks for explaining. In the case of an internal soundcard it's reasonable to expect a fail-fast style behaviour but I think you can argue it either way. However, I see how the alternate behaviour is more flexible so seems a valid improvement for someone to take on.
Sign in to join this conversation.
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/librespot#664
No description provided.