diff --git a/asio-sys/src/bindings/errors.rs b/asio-sys/src/bindings/errors.rs index 0c92d02..43f41bb 100644 --- a/asio-sys/src/bindings/errors.rs +++ b/asio-sys/src/bindings/errors.rs @@ -11,14 +11,14 @@ pub enum AsioDriverError { #[derive(Debug)] pub enum AsioError { - NoDrivers, - HardwareMalfunction, - InvalidInput, - BadMode, - HardwareStuck, - NoRate, - ASE_NoMemory, - UnknownError, + NoDrivers, + HardwareMalfunction, + InvalidInput, + BadMode, + HardwareStuck, + NoRate, + ASE_NoMemory, + UnknownError, } #[derive(Debug)] @@ -62,7 +62,7 @@ impl fmt::Display for AsioError { match *self { AsioError::NoDrivers => { write!(f, "hardware input or output is not present or available") - }, + } AsioError::HardwareMalfunction => write!( f, "hardware is malfunctioning (can be returned by any ASIO function)" @@ -89,7 +89,7 @@ impl Error for AsioError { AsioError::NoDrivers => "hardware input or output is not present or available", AsioError::HardwareMalfunction => { "hardware is malfunctioning (can be returned by any ASIO function)" - }, + } AsioError::InvalidInput => "input parameter invalid", AsioError::BadMode => "hardware is in a bad mode or used in a bad mode", AsioError::HardwareStuck => "hardware is not running when sample position is inquired", diff --git a/asio-sys/src/bindings/mod.rs b/asio-sys/src/bindings/mod.rs index fada89c..e4e0376 100644 --- a/asio-sys/src/bindings/mod.rs +++ b/asio-sys/src/bindings/mod.rs @@ -15,14 +15,6 @@ use num; // Bindings import use self::asio_import as ai; -// TODO I dont think this is needed anymore -/* -pub struct CbArgs { - pub stream_id: S, - pub data: D, -} -*/ - /// Holds the pointer to the callbacks that come from cpal struct BufferCallback(Box); @@ -231,16 +223,14 @@ impl Drivers { pub fn load(driver_name: &str) -> Result { let mut drivers = get_drivers(); // Make owned CString to send to load driver - let mut my_driver_name = CString::new(driver_name).expect("Can't go from str to CString"); - let raw = my_driver_name.into_raw(); + let my_driver_name = CString::new(driver_name).expect("Can't go from str to CString"); let mut driver_info = ai::ASIODriverInfo { _bindgen_opaque_blob: [0u32; 43], }; unsafe { // Destroy old drivers and load new drivers. - let load_result = drivers.load(raw); - // Take back ownership - my_driver_name = CString::from_raw(raw); + //let load_result = drivers.load(raw); + let load_result = drivers.load(my_driver_name.as_ptr() as *mut i8); if load_result { // Initialize ASIO match drivers.asio_init(&mut driver_info) { diff --git a/src/platform/windows/asio/stream.rs b/src/platform/windows/asio/stream.rs index b439bf5..8420d52 100644 --- a/src/platform/windows/asio/stream.rs +++ b/src/platform/windows/asio/stream.rs @@ -14,6 +14,8 @@ use SampleFormat; use StreamData; use UnknownTypeInputBuffer; use UnknownTypeOutputBuffer; +use std::thread; +use std::time::Duration; /// Controls all streams pub struct EventLoop { @@ -812,9 +814,8 @@ impl EventLoop { } let any_playing = streams .iter() - .filter(|s| if let Some(s) = s { s.playing } else { false }) - .next(); - if let None = any_playing { + .any(|s| if let Some(s) = s { s.playing } else { false }); + if any_playing { sys::stop(); } } @@ -846,8 +847,9 @@ impl EventLoop { .unwrap() .push(unsafe { mem::transmute(callback) }); loop { - // Might need a sleep here to prevent the loop being + // A sleep here to prevent the loop being // removed in --release + thread::sleep(Duration::new(1u64, 0u32)); } } }