Majority of ASIO host update following refactor

Currently not compiling - still need to address some global items within
asio-sys, including the `set_callback` function and the double buffer
globals.
This commit is contained in:
mitchmindtree 2019-06-28 04:43:58 +10:00
parent efe683133c
commit d739a5b79d
5 changed files with 788 additions and 741 deletions

View file

@ -16,8 +16,9 @@ use {
SupportedFormatsError,
};
pub use self::device::{Device, Devices, SupportedInputFormats, SupportedOutputFormats, default_input_device, default_output_device};
pub use self::device::{Device, Devices, SupportedInputFormats, SupportedOutputFormats};
pub use self::stream::{EventLoop, StreamId};
use std::sync::Arc;
mod device;
mod stream;
@ -25,12 +26,15 @@ mod asio_utils;
/// The host for ASIO.
#[derive(Debug)]
pub struct Host;
pub struct Host {
asio: Arc<sys::Asio>,
}
impl Host {
pub fn new() -> Result<Self, crate::HostUnavailable> {
//unimplemented!("asio as an initialisation and termination process that needs to be impld");
Ok(Host)
let asio = Arc::new(sys::Asio::new());
let host = Host { asio };
Ok(host)
}
}
@ -45,15 +49,17 @@ impl HostTrait for Host {
}
fn devices(&self) -> Result<Self::Devices, DevicesError> {
Devices::new()
Devices::new(self.asio.clone())
}
fn default_input_device(&self) -> Option<Self::Device> {
default_input_device()
// ASIO has no concept of a default device, so just use the first.
self.input_devices().ok().and_then(|mut ds| ds.next())
}
fn default_output_device(&self) -> Option<Self::Device> {
default_output_device()
// ASIO has no concept of a default device, so just use the first.
self.output_devices().ok().and_then(|mut ds| ds.next())
}
fn event_loop(&self) -> Self::EventLoop {