mirror of
https://github.com/librespot-org/librespot.git
synced 2024-12-18 17:11:53 +00:00
Prevent crash in audio_backend/alsa.rs when switching from Kodi audio to librespot
This commit is contained in:
parent
b6a38780df
commit
752a6b1df4
1 changed files with 9 additions and 2 deletions
|
@ -18,10 +18,17 @@ impl Sink for AlsaSink {
|
||||||
fn start(&mut self) -> io::Result<()> {
|
fn start(&mut self) -> io::Result<()> {
|
||||||
if self.0.is_some() {
|
if self.0.is_some() {
|
||||||
} else {
|
} else {
|
||||||
self.0 = Some(PCM::open(&*self.1,
|
match PCM::open(&*self.1,
|
||||||
Stream::Playback, Mode::Blocking,
|
Stream::Playback, Mode::Blocking,
|
||||||
Format::Signed16, Access::Interleaved,
|
Format::Signed16, Access::Interleaved,
|
||||||
2, 44100).ok().unwrap());
|
2, 44100) {
|
||||||
|
Ok(f) => self.0 = Some(f),
|
||||||
|
Err(e) => {
|
||||||
|
self.0 = None;
|
||||||
|
error!("Alsa error PCM open {}", e);
|
||||||
|
return Err(io::Error::new(io::ErrorKind::Other, "Alsa error: PCM open failed"));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue