minor fixes

This commit is contained in:
Tom Gowan 2018-11-07 14:59:38 +11:00 committed by mitchmindtree
parent 062205160c
commit 7950045240
3 changed files with 19 additions and 27 deletions

View File

@ -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",

View File

@ -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<S, D> {
pub stream_id: S,
pub data: D,
}
*/
/// Holds the pointer to the callbacks that come from cpal
struct BufferCallback(Box<FnMut(i32) + Send>);
@ -231,16 +223,14 @@ impl Drivers {
pub fn load(driver_name: &str) -> Result<Self, AsioDriverError> {
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) {

View File

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