Ignore play/pause errors for ALSA Stream

This commit is contained in:
Alex Moon 2020-04-12 13:11:35 -04:00
parent 62d540d396
commit b386e63eec
2 changed files with 9 additions and 6 deletions

View File

@ -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()
};

View File

@ -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};
@ -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)
}
@ -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(())
}
}