diff --git a/src/host/coreaudio/mod.rs b/src/host/coreaudio/mod.rs index d37de7b..85da95e 100644 --- a/src/host/coreaudio/mod.rs +++ b/src/host/coreaudio/mod.rs @@ -7,6 +7,7 @@ use BuildStreamError; use DefaultFormatError; use Device as DeviceTrait; use DeviceNameError; +use DevicesError; use EventLoop as EventLoopTrait; use Format; use Host as HostTrait; diff --git a/src/host/null/mod.rs b/src/host/null/mod.rs index 45b6b9b..d45200f 100644 --- a/src/host/null/mod.rs +++ b/src/host/null/mod.rs @@ -31,6 +31,12 @@ pub struct StreamId; pub struct SupportedInputFormats; pub struct SupportedOutputFormats; +impl Host { + pub fn new() -> Result { + Ok(Host) + } +} + impl Devices { pub fn new() -> Result { Ok(Devices) diff --git a/src/platform/mod.rs b/src/platform/mod.rs index ef6a635..0327aea 100644 --- a/src/platform/mod.rs +++ b/src/platform/mod.rs @@ -4,6 +4,9 @@ //! type and its associated `EventLoop`, `Device`, `StreamId` and other associated types. These //! types are useful in the case that users require switching between audio host APIs at runtime. +#[doc(inline)] +pub use self::platform_impl::*; + // A macro to assist with implementing a platform's dynamically dispatched `Host` type. // // These dynamically dispatched types are necessary to allow for users to switch between hosts at @@ -412,41 +415,57 @@ macro_rules! impl_platform_host { // TODO: Add pulseaudio and jack here eventually. #[cfg(any(target_os = "linux", target_os = "freebsd"))] -impl_platform_host!(Alsa alsa); +mod platform_impl { + pub use crate::host::alsa::Host as AlsaHost; + + /// The default host for the current compilation target platform. + pub type DefaultHost = crate::host::alsa::Host; + + impl_platform_host!(Alsa alsa); +} + #[cfg(any(target_os = "macos", target_os = "ios"))] -impl_platform_host!(CoreAudio coreaudio); +mod platform_impl { + pub use crate::host::coreaudio::Host as CoreAudioHost; + + /// The default host for the current compilation target platform. + pub type DefaultHost = crate::host::coreaudio::Host; + + impl_platform_host!(CoreAudio coreaudio); +} #[cfg(target_os = "emscripten")] -impl_platform_host!(Emscripten emscripten); +mod platform_impl { + pub use crate::host::emscripten::Host as EmscriptenHost; + + /// The default host for the current compilation target platform. + pub type DefaultHost = crate::host::emscripten::Host; + + impl_platform_host!(Emscripten emscripten); +} // TODO: Add `Asio asio` once #221 lands. #[cfg(windows)] -impl_platform_host!(Wasapi wasapi); +mod platform_impl { + pub use crate::host::wasapi::Host as WasapiHost; + + /// The default host for the current compilation target platform. + pub type DefaultHost = crate::host::wasapi::Host; + + impl_platform_host!(Wasapi wasapi); +} #[cfg(not(any(windows, target_os = "linux", target_os = "freebsd", target_os = "macos", target_os = "ios", target_os = "emscripten")))] -impl_platform_host!(Null null); +mod platform_impl { + pub use crate::host::null::Host as NullHost; -/// The default host for the current compilation target platform. -#[cfg(any(target_os = "linux", target_os = "freebsd"))] -pub type DefaultHost = crate::host::alsa::Host; + /// The default host for the current compilation target platform. + pub type DefaultHost = crate::host::null::Host; -/// The default host for the current compilation target platform. -#[cfg(any(target_os = "macos", target_os = "ios"))] -pub type DefaultHost = crate::host::coreaudio::Host; - -/// The default host for the current compilation target platform. -#[cfg(target_os = "emscripten")] -pub type DefaultHost = crate::host::emscripten::Host; - -#[cfg(not(any(windows, target_os = "linux", target_os = "freebsd", target_os = "macos", - target_os = "ios", target_os = "emscripten")))] -pub type DefaultHost = crate::host::null::Host; - -/// The default host for the current compilation target platform. -#[cfg(windows)] -pub type DefaultHost = crate::host::wasapi::Host; + impl_platform_host!(Null null); +} /// Retrieve the default host for the system. ///