Skip to content

Commit

Permalink
Ignore play/pause errors for ALSA Stream
Browse files Browse the repository at this point in the history
  • Loading branch information
alexmoon committed Apr 12, 2020
1 parent 62d540d commit b386e63
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
6 changes: 4 additions & 2 deletions src/host/alsa/enumerate.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,13 +49,15 @@ impl Iterator for Devices {

// See if the device has an available output stream.
let has_available_output = {
let playback_handle = alsa::pcm::PCM::new(&name, alsa::Direction::Playback, true);
let playback_handle =
alsa::pcm::PCM::new(&name, alsa::Direction::Playback, true);
playback_handle.is_ok()
};

// See if the device has an available input stream.
let has_available_input = {
let capture_handle = alsa::pcm::PCM::new(&name, alsa::Direction::Capture, true);
let capture_handle =
alsa::pcm::PCM::new(&name, alsa::Direction::Capture, true);
capture_handle.is_ok()
};

Expand Down
9 changes: 5 additions & 4 deletions src/host/alsa/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,10 @@ use crate::{
StreamConfig, StreamError, SupportedStreamConfig, SupportedStreamConfigRange,
SupportedStreamConfigsError,
};
use std::cmp;
use std::sync::Arc;
use std::thread::{self, JoinHandle};
use std::vec::IntoIter as VecIntoIter;
use std::cmp;
use traits::{DeviceTrait, HostTrait, StreamTrait};

pub use self::enumerate::{default_input_device, default_output_device, Devices};
Expand Down Expand Up @@ -173,7 +173,8 @@ impl Device {
) -> Result<StreamInner, BuildStreamError> {
let name = &self.0;

let handle = match alsa::pcm::PCM::new(name, stream_type, true).map_err(|e| (e, e.errno())) {
let handle = match alsa::pcm::PCM::new(name, stream_type, true).map_err(|e| (e, e.errno()))
{
Err((_, Some(nix::errno::Errno::EBUSY))) => {
return Err(BuildStreamError::DeviceNotAvailable)
}
Expand Down Expand Up @@ -747,11 +748,11 @@ impl Drop for Stream {

impl StreamTrait for Stream {
fn play(&self) -> Result<(), PlayStreamError> {
self.inner.channel.pause(false)?;
self.inner.channel.pause(false).ok();
Ok(())
}
fn pause(&self) -> Result<(), PauseStreamError> {
self.inner.channel.pause(true)?;
self.inner.channel.pause(true).ok();
Ok(())
}
}
Expand Down

0 comments on commit b386e63

Please sign in to comment.