Update for rustc

This commit is contained in:
Pierre Krieger 2015-01-05 10:52:59 +01:00
parent 546c3acb87
commit 420a0f0fd4
3 changed files with 15 additions and 9 deletions

View File

@ -1,7 +1,7 @@
[package]
name = "cpal"
version = "0.0.6-pre"
version = "0.0.7-pre"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
description = "Cross-platform audio playing library in pure Rust."
repository = "https://github.com/tomaka/cpal"
@ -10,11 +10,11 @@ license = "Apache-2.0"
keywords = ["audio", "sound"]
[target.i686-pc-windows-gnu.dependencies.winapi]
version = "^0.0.3"
version = "0"
features = ["ole32"]
[target.x86_64-pc-windows-gnu.dependencies.winapi]
version = "^0.0.3"
version = "0"
features = ["ole32"]
[target.i686-unknown-linux-gnu.dependencies.alsa-sys]
@ -26,4 +26,4 @@ version = "^0.0.1"
path = "alsa-sys"
[dev-dependencies]
vorbis = "^0.0.1"
vorbis = "0"

View File

@ -47,6 +47,7 @@ a conversion on your data.
If you have the possibility, you should try to match the format of the voice.
*/
#![feature(associated_types)]
#![feature(macro_rules)]
#![feature(unsafe_destructor)]
#![unstable]
@ -56,6 +57,8 @@ use this_platform_is_not_supported;
pub use samples_formats::{SampleFormat, Sample};
use std::ops::{Deref, DerefMut};
mod conversions;
mod samples_formats;
@ -84,7 +87,7 @@ pub struct Voice(cpal_impl::Voice);
pub type ChannelsCount = u16;
///
#[deriving(Show, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
#[derive(Show, Clone, Copy, PartialEq, Eq, PartialOrd, Ord)]
pub struct SamplesRate(pub u32);
/// Represents a buffer that must be filled with audio data.
@ -199,7 +202,8 @@ impl Voice {
let intermediate_buffer_length = intermediate_buffer_length *
source_samples_format.get_sample_size() /
target_samples_format.get_sample_size();
let intermediate_buffer = Vec::from_elem(intermediate_buffer_length, unsafe { std::mem::uninitialized() });
let intermediate_buffer = std::iter::repeat(unsafe { std::mem::uninitialized() })
.take(intermediate_buffer_length).collect();
Buffer {
target: Some(target_buffer),
@ -241,13 +245,15 @@ impl Voice {
}
}
impl<'a, T> Deref<[T]> for Buffer<'a, T> {
impl<'a, T> Deref for Buffer<'a, T> {
type Target = [T];
fn deref(&self) -> &[T] {
panic!("It is forbidden to read from the audio buffer");
}
}
impl<'a, T> DerefMut<[T]> for Buffer<'a, T> {
impl<'a, T> DerefMut for Buffer<'a, T> {
fn deref_mut(&mut self) -> &mut [T] {
if let Some(ref mut conversion) = self.conversion {
conversion.intermediate_buffer.as_mut_slice()

View File

@ -2,7 +2,7 @@ use std::borrow::Cow;
use std::mem;
/// Format that each sample has.
#[deriving(Clone, Copy, Show, PartialEq, Eq)]
#[derive(Clone, Copy, Show, PartialEq, Eq)]
pub enum SampleFormat {
/// The value 0 corresponds to 0.
I16,