Ignore play/pause errors for ALSA Stream
This commit is contained in:
parent
62d540d396
commit
b386e63eec
|
@ -49,13 +49,15 @@ impl Iterator for Devices {
|
||||||
|
|
||||||
// See if the device has an available output stream.
|
// See if the device has an available output stream.
|
||||||
let has_available_output = {
|
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()
|
playback_handle.is_ok()
|
||||||
};
|
};
|
||||||
|
|
||||||
// See if the device has an available input stream.
|
// See if the device has an available input stream.
|
||||||
let has_available_input = {
|
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()
|
capture_handle.is_ok()
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -8,10 +8,10 @@ use crate::{
|
||||||
StreamConfig, StreamError, SupportedStreamConfig, SupportedStreamConfigRange,
|
StreamConfig, StreamError, SupportedStreamConfig, SupportedStreamConfigRange,
|
||||||
SupportedStreamConfigsError,
|
SupportedStreamConfigsError,
|
||||||
};
|
};
|
||||||
|
use std::cmp;
|
||||||
use std::sync::Arc;
|
use std::sync::Arc;
|
||||||
use std::thread::{self, JoinHandle};
|
use std::thread::{self, JoinHandle};
|
||||||
use std::vec::IntoIter as VecIntoIter;
|
use std::vec::IntoIter as VecIntoIter;
|
||||||
use std::cmp;
|
|
||||||
use traits::{DeviceTrait, HostTrait, StreamTrait};
|
use traits::{DeviceTrait, HostTrait, StreamTrait};
|
||||||
|
|
||||||
pub use self::enumerate::{default_input_device, default_output_device, Devices};
|
pub use self::enumerate::{default_input_device, default_output_device, Devices};
|
||||||
|
@ -173,7 +173,8 @@ impl Device {
|
||||||
) -> Result<StreamInner, BuildStreamError> {
|
) -> Result<StreamInner, BuildStreamError> {
|
||||||
let name = &self.0;
|
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))) => {
|
Err((_, Some(nix::errno::Errno::EBUSY))) => {
|
||||||
return Err(BuildStreamError::DeviceNotAvailable)
|
return Err(BuildStreamError::DeviceNotAvailable)
|
||||||
}
|
}
|
||||||
|
@ -747,11 +748,11 @@ impl Drop for Stream {
|
||||||
|
|
||||||
impl StreamTrait for Stream {
|
impl StreamTrait for Stream {
|
||||||
fn play(&self) -> Result<(), PlayStreamError> {
|
fn play(&self) -> Result<(), PlayStreamError> {
|
||||||
self.inner.channel.pause(false)?;
|
self.inner.channel.pause(false).ok();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
fn pause(&self) -> Result<(), PauseStreamError> {
|
fn pause(&self) -> Result<(), PauseStreamError> {
|
||||||
self.inner.channel.pause(true)?;
|
self.inner.channel.pause(true).ok();
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue