Merge pull request #62 from tomaka/restore-null

Restore the null implementation and compile it every time
This commit is contained in:
tomaka 2015-09-10 19:51:35 +02:00
commit 36b1a6d016
2 changed files with 59 additions and 12 deletions

View File

@ -42,10 +42,14 @@ extern crate lazy_static;
pub use samples_formats::{SampleFormat, Sample}; pub use samples_formats::{SampleFormat, Sample};
#[cfg(all(not(windows), not(unix)))]
use null as cpal_impl;
use std::fmt; use std::fmt;
use std::error::Error; use std::error::Error;
use std::ops::{Deref, DerefMut}; use std::ops::{Deref, DerefMut};
mod null;
mod samples_formats; mod samples_formats;
#[cfg(target_os = "linux")] #[cfg(target_os = "linux")]
@ -60,10 +64,6 @@ mod cpal_impl;
#[path="coreaudio/mod.rs"] #[path="coreaudio/mod.rs"]
mod cpal_impl; 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. /// An iterator for the list of formats that are supported by the backend.
pub struct EndpointsIterator(cpal_impl::EndpointsIterator); pub struct EndpointsIterator(cpal_impl::EndpointsIterator);

View File

@ -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<Endpoint> {
None
}
}
pub fn get_default_endpoint() -> Option<Endpoint> {
None
}
#[derive(Clone, Debug, PartialEq, Eq)]
pub struct Endpoint;
impl Endpoint {
pub fn get_supported_formats_list(&self)
-> Result<SupportedFormatsIterator, FormatsEnumerationError>
{
unreachable!()
}
}
pub struct SupportedFormatsIterator;
impl Iterator for SupportedFormatsIterator {
type Item = Format;
fn next(&mut self) -> Option<Format> {
None
}
}
pub struct Voice; pub struct Voice;
pub struct Buffer<'a, T>;
impl Voice { impl Voice {
pub fn new() -> Voice { pub fn new(_: &Endpoint, _: &Format) -> Result<Voice, CreationError> {
Voice Err(CreationError::DeviceNotAvailable)
} }
pub fn get_channels(&self) -> ::ChannelsCount { pub fn get_channels(&self) -> ::ChannelsCount {
2 unreachable!()
} }
pub fn get_samples_rate(&self) -> ::SamplesRate { pub fn get_samples_rate(&self) -> ::SamplesRate {
::SamplesRate(44100) unreachable!()
} }
pub fn get_samples_format(&self) -> ::SampleFormat { pub fn get_samples_format(&self) -> ::SampleFormat {
::SampleFormat::U16 unreachable!()
} }
pub fn append_data<'a, T>(&'a mut self, _: usize) -> Buffer<'a, T> { pub fn append_data<'a, T>(&'a mut self, _: usize) -> Buffer<'a, T> {
Buffer unreachable!()
} }
pub fn play(&mut self) { 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> { impl<'a, T> Buffer<'a, T> {
pub fn get_buffer<'b>(&'b mut self) -> &'b mut [T] { pub fn get_buffer<'b>(&'b mut self) -> &'b mut [T] {
[].as_mut_slice() unreachable!()
} }
pub fn finish(self) { pub fn finish(self) {