diff --git a/src/lib.rs b/src/lib.rs index c1d8dac..7e77b94 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -42,10 +42,14 @@ extern crate lazy_static; pub use samples_formats::{SampleFormat, Sample}; +#[cfg(all(not(windows), not(unix)))] +use null as cpal_impl; + use std::fmt; use std::error::Error; use std::ops::{Deref, DerefMut}; +mod null; mod samples_formats; #[cfg(target_os = "linux")] @@ -60,10 +64,6 @@ mod cpal_impl; #[path="coreaudio/mod.rs"] mod cpal_impl; -#[cfg(all(not(windows), not(unix)))] -#[path="null/mod.rs"] -mod cpal_impl; - /// An iterator for the list of formats that are supported by the backend. pub struct EndpointsIterator(cpal_impl::EndpointsIterator); diff --git a/src/null/mod.rs b/src/null/mod.rs index 325d691..ff5e1db 100644 --- a/src/null/mod.rs +++ b/src/null/mod.rs @@ -1,25 +1,68 @@ +#![allow(dead_code)] + +use std::marker::PhantomData; + +use CreationError; +use Format; +use FormatsEnumerationError; + +#[derive(Default)] +pub struct EndpointsIterator; + +impl Iterator for EndpointsIterator { + type Item = Endpoint; + + fn next(&mut self) -> Option { + None + } +} + +pub fn get_default_endpoint() -> Option { + None +} + +#[derive(Clone, Debug, PartialEq, Eq)] +pub struct Endpoint; + +impl Endpoint { + pub fn get_supported_formats_list(&self) + -> Result + { + unreachable!() + } +} + +pub struct SupportedFormatsIterator; + +impl Iterator for SupportedFormatsIterator { + type Item = Format; + + fn next(&mut self) -> Option { + None + } +} + pub struct Voice; -pub struct Buffer<'a, T>; impl Voice { - pub fn new() -> Voice { - Voice + pub fn new(_: &Endpoint, _: &Format) -> Result { + Err(CreationError::DeviceNotAvailable) } pub fn get_channels(&self) -> ::ChannelsCount { - 2 + unreachable!() } pub fn get_samples_rate(&self) -> ::SamplesRate { - ::SamplesRate(44100) + unreachable!() } pub fn get_samples_format(&self) -> ::SampleFormat { - ::SampleFormat::U16 + unreachable!() } pub fn append_data<'a, T>(&'a mut self, _: usize) -> Buffer<'a, T> { - Buffer + unreachable!() } pub fn play(&mut self) { @@ -29,9 +72,13 @@ impl Voice { } } +pub struct Buffer<'a, T: 'a> { + marker: PhantomData<&'a T>, +} + impl<'a, T> Buffer<'a, T> { pub fn get_buffer<'b>(&'b mut self) -> &'b mut [T] { - [].as_mut_slice() + unreachable!() } pub fn finish(self) {