Fix remaining compile errors for ASIO host

Now runs the beep and enumerate examples nicely! Time to do a proper
code review of the ASIO stuff and see how to best take advantage of the
new `Host` API.
This commit is contained in:
mitchmindtree 2019-06-27 21:49:27 +10:00
parent 747caeee38
commit 05f8b7dc43
4 changed files with 14 additions and 8 deletions

View File

@ -5,6 +5,7 @@ pub type SupportedOutputFormats = std::vec::IntoIter<SupportedFormat>;
use std::hash::{Hash, Hasher};
use DefaultFormatError;
use DeviceNameError;
use DevicesError;
use Format;
use SampleFormat;
use SampleRate;

View File

@ -7,13 +7,14 @@ use {
DeviceNameError,
DevicesError,
EventLoop as EventLoopTrait,
Format,
Host as HostTrait,
PauseStreamError,
PlayStreamError,
StreamDataResult,
StreamId as StreamIdTrait,
SupportedFormatsError,
}
};
pub use self::device::{Device, Devices, SupportedInputFormats, SupportedOutputFormats, default_input_device, default_output_device};
pub use self::stream::{EventLoop, StreamId};
@ -28,8 +29,8 @@ pub struct Host;
impl Host {
pub fn new() -> Result<Self, crate::HostUnavailable> {
unimplemented!("asio as an initialisation and termination process that needs to be impld");
//Ok(Host)
//unimplemented!("asio as an initialisation and termination process that needs to be impld");
Ok(Host)
}
}
@ -39,7 +40,8 @@ impl HostTrait for Host {
type EventLoop = EventLoop;
fn is_available() -> bool {
unimplemented!("check how to do this using asio-sys")
true
//unimplemented!("check how to do this using asio-sys")
}
fn devices(&self) -> Result<Self::Devices, DevicesError> {

View File

@ -679,10 +679,6 @@ impl EventLoop {
) => {
let mut my_buffers = $Buffers;
{
// Wrap the cpal buffer
let buff = OutputBuffer {
buffer: &mut my_buffers.cpal,
};
// call the callback to fill the buffer with
// users data
callback(
@ -894,6 +890,7 @@ impl EventLoop {
}
// Calling play when already playing is a no-op
sys::play();
Ok(())
}
/// Pause the cpal stream for the given ID.
@ -912,6 +909,7 @@ impl EventLoop {
if any_playing {
sys::stop();
}
Ok(())
}
/// Destroy the cpal stream based on the ID.

View File

@ -269,6 +269,7 @@ macro_rules! impl_platform_host {
.map(StreamId)
}
)*
_ => panic!("tried to build a stream with a device from another host"),
}
}
@ -285,6 +286,7 @@ macro_rules! impl_platform_host {
.map(StreamId)
}
)*
_ => panic!("tried to build a stream with a device from another host"),
}
}
@ -295,6 +297,7 @@ macro_rules! impl_platform_host {
e.play_stream(s.clone())
}
)*
_ => panic!("tried to play a stream with an ID associated with another host"),
}
}
@ -305,6 +308,7 @@ macro_rules! impl_platform_host {
e.pause_stream(s.clone())
}
)*
_ => panic!("tried to pause a stream with an ID associated with another host"),
}
}
@ -315,6 +319,7 @@ macro_rules! impl_platform_host {
e.destroy_stream(s.clone())
}
)*
_ => panic!("tried to destroy a stream with an ID associated with another host"),
}
}