Add basic API

This commit is contained in:
Pierre Krieger 2014-12-11 17:23:33 +01:00
parent 6b48a00758
commit 873779aaa8
4 changed files with 191 additions and 26 deletions

View file

@ -1,3 +1,4 @@
#![feature(unsafe_destructor)]
#[cfg(all(not(windows)))]
use this_platform_is_not_supported;
@ -5,3 +6,34 @@ use this_platform_is_not_supported;
#[cfg(windows)]
#[path="wasapi/mod.rs"]
pub mod cpal_impl;
pub struct Channel(cpal_impl::Channel);
pub struct Buffer<'a, T>(cpal_impl::Buffer<'a, T>);
impl Channel {
pub fn new() -> Channel {
let channel = cpal_impl::Channel::new();
Channel(channel)
}
pub fn get_channels(&self) -> u16 {
self.0.get_channels()
}
pub fn append_data<'a, T>(&'a mut self) -> Buffer<'a, T> {
Buffer(self.0.append_data())
}
}
impl<'a, T> Deref<[T]> for Buffer<'a, T> {
fn deref(&self) -> &[T] {
panic!()
}
}
impl<'a, T> DerefMut<[T]> for Buffer<'a, T> {
fn deref_mut(&mut self) -> &mut [T] {
self.0.get_buffer()
}
}