From 05f8b7dc43b6b45258e4d04d0e2eece5a308744e Mon Sep 17 00:00:00 2001 From: mitchmindtree Date: Thu, 27 Jun 2019 21:49:27 +1000 Subject: [PATCH] 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. --- src/host/asio/device.rs | 1 + src/host/asio/mod.rs | 10 ++++++---- src/host/asio/stream.rs | 6 ++---- src/platform/mod.rs | 5 +++++ 4 files changed, 14 insertions(+), 8 deletions(-) diff --git a/src/host/asio/device.rs b/src/host/asio/device.rs index c6c085b..a0741e3 100644 --- a/src/host/asio/device.rs +++ b/src/host/asio/device.rs @@ -5,6 +5,7 @@ pub type SupportedOutputFormats = std::vec::IntoIter; use std::hash::{Hash, Hasher}; use DefaultFormatError; use DeviceNameError; +use DevicesError; use Format; use SampleFormat; use SampleRate; diff --git a/src/host/asio/mod.rs b/src/host/asio/mod.rs index f1b22dc..028c919 100644 --- a/src/host/asio/mod.rs +++ b/src/host/asio/mod.rs @@ -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 { - 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 { diff --git a/src/host/asio/stream.rs b/src/host/asio/stream.rs index 2beb37d..6b484c9 100644 --- a/src/host/asio/stream.rs +++ b/src/host/asio/stream.rs @@ -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. diff --git a/src/platform/mod.rs b/src/platform/mod.rs index f97697e..7eb2081 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -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"), } }