Add a "null" implementation for platforms that aren't supported

This commit is contained in:
Pierre Krieger 2015-01-09 16:06:24 +01:00
parent 234ccfee63
commit 48efe03661
2 changed files with 43 additions and 3 deletions

View File

@ -51,9 +51,6 @@ If you have the possibility, you should try to match the format of the voice.
#![feature(unsafe_destructor)] #![feature(unsafe_destructor)]
#![unstable] #![unstable]
#[cfg(all(not(windows), not(unix)))]
use this_platform_is_not_supported;
pub use samples_formats::{SampleFormat, Sample}; pub use samples_formats::{SampleFormat, Sample};
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
@ -68,6 +65,10 @@ mod cpal_impl;
#[path="wasapi/mod.rs"] #[path="wasapi/mod.rs"]
mod cpal_impl; mod cpal_impl;
#[cfg(all(not(windows), not(unix)))]
#[path="null/mod.rs"]
mod cpal_impl;
/// Controls a sound output. A typical application has one `Voice` for each sound /// Controls a sound output. A typical application has one `Voice` for each sound
/// it wants to output. /// it wants to output.
/// ///

39
src/null/mod.rs Normal file
View File

@ -0,0 +1,39 @@
pub struct Voice;
pub struct Buffer<'a, T>;
impl Voice {
pub fn new() -> Voice {
Voice
}
pub fn get_channels(&self) -> ::ChannelsCount {
2
}
pub fn get_samples_rate(&self) -> ::SamplesRate {
::SamplesRate(44100)
}
pub fn get_samples_format(&self) -> ::SampleFormat {
::SampleFormat::U16
}
pub fn append_data<'a, T>(&'a mut self, _: uint) -> Buffer<'a, T> {
Buffer
}
pub fn play(&mut self) {
}
pub fn pause(&mut self) {
}
}
impl<'a, T> Buffer<'a, T> {
pub fn get_buffer<'b>(&'b mut self) -> &'b mut [T] {
[].as_mut_slice()
}
pub fn finish(self) {
}
}