Skip to content

Commit

Permalink
Merge pull request #11 from thekr1s/alsa-open-crash
Browse files Browse the repository at this point in the history
Prevent crash in audio_backend/alsa.rs when switching from Kodi audio…
  • Loading branch information
sashahilton00 authored Feb 7, 2018
2 parents 578d6b7 + b03430a commit 53fab4d
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions src/audio_backend/alsa.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,17 @@ impl Open for AlsaSink {

impl Sink for AlsaSink {
fn start(&mut self) -> io::Result<()> {
if self.0.is_some() {
} else {
self.0 = Some(PCM::open(&*self.1,
if self.0.is_none() {
match PCM::open(&*self.1,
Stream::Playback, Mode::Blocking,
Format::Signed16, Access::Interleaved,
2, 44100).ok().unwrap());
2, 44100) {
Ok(f) => self.0 = Some(f),
Err(e) => {
error!("Alsa error PCM open {}", e);
return Err(io::Error::new(io::ErrorKind::Other, "Alsa error: PCM open failed"));
}
}
}
Ok(())
}
Expand Down

0 comments on commit 53fab4d

Please sign in to comment.