plietar / librespot

Open Source Spotify client library
MIT License
1.14k stars 185 forks source link

Main thread panicks when sound device unavailable #165

Open TonioRoffo opened 7 years ago

TonioRoffo commented 7 years ago

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.

ash-vd commented 7 years ago

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