asio: Re-add possibility to create stream individually

This commit is contained in:
msiglreith 2019-10-08 16:22:06 +02:00 • committed by mitchmindtree
parent bfda575218
commit 972cce0f8c
4 changed files with 79 additions and 59 deletions

View file

@ -3,7 +3,7 @@ pub type SupportedInputFormats = std::vec::IntoIter<SupportedFormat>;
pub type SupportedOutputFormats = std::vec::IntoIter<SupportedFormat>;
use std::hash::{Hash, Hasher};
use std::sync::{Mutex, Arc};
use std::sync::{Arc};
use BackendSpecificError;
use DefaultFormatError;
use DeviceNameError;
@ -14,6 +14,7 @@ use SampleRate;
use SupportedFormat;
use SupportedFormatsError;
use super::sys;
use super::parking_lot::Mutex;
/// A ASIO Device
pub struct Device {
@ -23,7 +24,7 @@ pub struct Device {
// Input and/or Output stream.
// An driver can only have one of each.
// They need to be created at the same time.
pub asio_streams: Arc<Mutex<Option<sys::AsioStreams>>>,
pub asio_streams: Arc<Mutex<sys::AsioStreams>>,
}
/// All available devices.
@ -154,7 +155,10 @@ impl Iterator for Devices {
Some(name) => match self.asio.load_driver(&name) {
Ok(driver) => {
let driver = Arc::new(driver);
let asio_streams = Arc::new(Mutex::new(None));
let asio_streams = Arc::new(Mutex::new(sys::AsioStreams {
input: None,
output: None,
}));
return Some(Device { driver, asio_streams });
}
Err(_) => continue,