[GH-ISSUE #50] Main thread panicks when sound device unavailable #38

Closed
opened 2026-02-27 19:28:27 +03:00 by kerem · 6 comments
Owner

Originally created by @sashahilton00 on GitHub (Jan 29, 2018).
Original GitHub issue: https://github.com/librespot-org/librespot/issues/50

Issue by TonioRoffo
Friday Mar 17, 2017 at 07:55 GMT
Originally opened as https://github.com/plietar/librespot/issues/165


Using:

./librespot -n SpotifyMain -b 320 --backend portaudio --device "NAD USB Audio 2.0: - (hw:2,0)"

commit eb49ff3 on Ubuntu 16.04

If the hardware is claimed by other software (or hardware not available) and spotify connect attempts to load a song, the main thread panicks & fails.

Suggestion is to make it fail gracefully and wait for the next command?

When started correctly and while paused, another program claims the soundcard:

INFO:librespot::player: Track "The Old Man Down The Road" loaded
INFO:librespot::player: Loading track "The Old Man Down The Road"
INFO:librespot::player: Track "The Old Man Down The Road" loaded
Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1736
Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir, &self->pcm )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1904
Expression 'PaAlsaStreamComponent_Initialize( &self->playback, alsaApi, outParams, StreamDirection_Out, NULL != callback )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2175
Expression 'PaAlsaStream_Initialize( stream, alsaHostApi, inputParameters, outputParameters, sampleRate, framesPerBuffer, callback, streamFlags, userData )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2840
thread '' panicked at 'called Result::unwrap() on an Err value: Device unavailable', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcore/result.rs:868
note: Run with RUST_BACKTRACE=1 for a backtrace.
thread 'main' panicked at 'called Result::unwrap() on an Err value: "SendError(..)"', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcore/result.rs:868

on another occasion, starting librespot while device already claimed:

thread '' panicked at 'Could not find device', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcore/option.rs:715
note: Run with RUST_BACKTRACE=1 for a backtrace.

Originally created by @sashahilton00 on GitHub (Jan 29, 2018). Original GitHub issue: https://github.com/librespot-org/librespot/issues/50 <a href="https://github.com/TonioRoffo"><img src="https://avatars0.githubusercontent.com/u/15906380?v=4" align="left" width="96" height="96" hspace="10"></img></a> **Issue by [TonioRoffo](https://github.com/TonioRoffo)** _Friday Mar 17, 2017 at 07:55 GMT_ _Originally opened as https://github.com/plietar/librespot/issues/165_ ---- Using: ./librespot -n SpotifyMain -b 320 --backend portaudio --device "NAD USB Audio 2.0: - (hw:2,0)" commit eb49ff3 on Ubuntu 16.04 If the hardware is claimed by other software (or hardware not available) and spotify connect attempts to load a song, the main thread panicks & fails. Suggestion is to make it fail gracefully and wait for the next command? When started correctly and while paused, another program claims the soundcard: > INFO:librespot::player: Track "The Old Man Down The Road" loaded > INFO:librespot::player: Loading track "The Old Man Down The Road" > INFO:librespot::player: Track "The Old Man Down The Road" loaded > Expression 'ret' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1736 > Expression 'AlsaOpen( &alsaApi->baseHostApiRep, params, streamDir, &self->pcm )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 1904 > Expression 'PaAlsaStreamComponent_Initialize( &self->playback, alsaApi, outParams, StreamDirection_Out, NULL != callback )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2175 > Expression 'PaAlsaStream_Initialize( stream, alsaHostApi, inputParameters, outputParameters, sampleRate, framesPerBuffer, callback, streamFlags, userData )' failed in 'src/hostapi/alsa/pa_linux_alsa.c', line: 2840 > **thread '<unnamed>' panicked at 'called `Result::unwrap()` on an `Err` value: Device unavailable',** /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcore/result.rs:868 > note: Run with `RUST_BACKTRACE=1` for a backtrace. > thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: "SendError(..)"', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcore/result.rs:868 on another occasion, starting librespot while device already claimed: > thread '<unnamed>' panicked at 'Could not find device', /buildslave/rust-buildbot/slave/stable-dist-rustc-linux/build/src/libcore/option.rs:715 > note: Run with `RUST_BACKTRACE=1` for a backtrace. >
kerem 2026-02-27 19:28:27 +03:00
Author
Owner

@sashahilton00 commented on GitHub (Jan 29, 2018):

Comment by ashwinvandijk
Tuesday May 02, 2017 at 07:46 GMT


Same issue here.. I run librespot in conjunction with snapcast, so I don't even use an audiodevice.

<!-- gh-comment-id:361262102 --> @sashahilton00 commented on GitHub (Jan 29, 2018): <a href="https://github.com/ashwinvandijk"><img src="https://avatars1.githubusercontent.com/u/9663397?v=4" align="left" width="48" height="48" hspace="10"></img></a> **Comment by [ashwinvandijk](https://github.com/ashwinvandijk)** _Tuesday May 02, 2017 at 07:46 GMT_ ---- Same issue here.. I run librespot in conjunction with snapcast, so I don't even use an audiodevice.
Author
Owner

@ComlOnline commented on GitHub (Jan 29, 2018):

@TonioRoffo @ashwinvandijk Do you know if you still have this issue?

<!-- gh-comment-id:361422358 --> @ComlOnline commented on GitHub (Jan 29, 2018): @TonioRoffo @ashwinvandijk Do you know if you still have this issue?
Author
Owner

@sashahilton00 commented on GitHub (Feb 7, 2018):

And if the issue does still exist, can you run with a backtrace?

<!-- gh-comment-id:363788563 --> @sashahilton00 commented on GitHub (Feb 7, 2018): And if the issue does still exist, can you run with a backtrace?
Author
Owner

@TonioRoffo commented on GitHub (Feb 7, 2018):

Sorry, no longer running librespot, can't assist further.

<!-- gh-comment-id:363789154 --> @TonioRoffo commented on GitHub (Feb 7, 2018): Sorry, no longer running librespot, can't assist further.
Author
Owner

@sashahilton00 commented on GitHub (Feb 7, 2018):

Ok, not a problem, thanks for replying. @ashwinvandijk is this still an issue for you?

<!-- gh-comment-id:363789573 --> @sashahilton00 commented on GitHub (Feb 7, 2018): Ok, not a problem, thanks for replying. @ashwinvandijk is this still an issue for you?
Author
Owner

@sashahilton00 commented on GitHub (Feb 25, 2018):

No response, and no further reports, so closing. Please open a new issue with a backtrace if you are having this issue.

<!-- gh-comment-id:368350350 --> @sashahilton00 commented on GitHub (Feb 25, 2018): No response, and no further reports, so closing. Please open a new issue with a backtrace if you are having this issue.
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#38
No description provided.