From 84326cb4a74170a1261a7241d0d8ece9679ee956 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Wed, 25 Mar 2015 11:21:10 +0100 Subject: [PATCH] Rustup --- Cargo.toml | 2 +- alsa-sys/Cargo.toml | 4 ++-- examples/music.rs | 6 ++---- src/conversions.rs | 8 ++++---- src/samples_formats.rs | 2 +- src/wasapi/mod.rs | 4 ++-- 6 files changed, 12 insertions(+), 14 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 831a7f3..6ce23e6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "cpal" -version = "0.0.15" +version = "0.0.16" authors = ["Pierre Krieger "] description = "Cross-platform audio playing library in pure Rust." repository = "https://github.com/tomaka/cpal" diff --git a/alsa-sys/Cargo.toml b/alsa-sys/Cargo.toml index 6673213..91bea7b 100644 --- a/alsa-sys/Cargo.toml +++ b/alsa-sys/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "alsa-sys" -version = "0.0.4" +version = "0.0.5" authors = ["Pierre Krieger "] build = "build.rs" description = "Bindings for the ALSA project (Advanced Linux Sound Architecture)" @@ -11,4 +11,4 @@ license = "MIT" libc = "*" [build-dependencies] -pkg-config = "^0.1.1" +pkg-config = "0.3" diff --git a/examples/music.rs b/examples/music.rs index 06d3c42..b351110 100644 --- a/examples/music.rs +++ b/examples/music.rs @@ -1,15 +1,13 @@ -#![feature(core, old_io)] - extern crate cpal; extern crate vorbis; -use std::old_io::BufReader; +use std::io::Cursor; fn main() { let mut channel = cpal::Voice::new(); channel.play(); - let mut decoder = vorbis::Decoder::new(BufReader::new(include_bytes!("music.ogg"))) + let mut decoder = vorbis::Decoder::new(Cursor::new(&include_bytes!("music.ogg")[..])) .unwrap(); 'main: for packet in decoder.packets() { diff --git a/src/conversions.rs b/src/conversions.rs index 94e24e5..b98a696 100644 --- a/src/conversions.rs +++ b/src/conversions.rs @@ -19,7 +19,7 @@ pub fn convert_samples_rate(input: &[T], from: ::SamplesRate, to: ::SamplesRa if from % to == 0 { let mut result = Vec::new(); for element in input.chunks(channels as usize * (from / to) as usize) { - for i in range(0, channels) { + for i in (0 .. channels) { result.push(element[i as usize]); } } @@ -74,13 +74,13 @@ pub fn convert_channels(input: &[T], from: ::ChannelsCount, to: ::ChannelsCou for element in input.chunks(from as usize) { // copying the common channels - for i in range(0, ::std::cmp::min(from, to)) { + for i in (0 .. ::std::cmp::min(from, to)) { result.push(element[i as usize]); } // adding extra ones if to > from { - for i in range(0, to - from) { + for i in (0 .. to - from) { result.push(element[i as usize % element.len()]); } } @@ -113,7 +113,7 @@ mod test { } #[test] - #[should_fail] + #[should_panic] fn convert_channels_wrong_data_len() { convert_channels(&[1u16, 2, 3], 2, 1); } diff --git a/src/samples_formats.rs b/src/samples_formats.rs index 4209e90..d9ecee4 100644 --- a/src/samples_formats.rs +++ b/src/samples_formats.rs @@ -83,7 +83,7 @@ impl Sample for i16 { fn to_vec_u16(input: &[i16]) -> Cow<[u16]> { Cow::Owned(input.iter().map(|&value| { if value < 0 { - (value + 32767) as u16 + 1 + (value + 32767 + 1) as u16 } else { (value as u16) + 32768 } diff --git a/src/wasapi/mod.rs b/src/wasapi/mod.rs index 8eab473..7d58910 100644 --- a/src/wasapi/mod.rs +++ b/src/wasapi/mod.rs @@ -60,7 +60,7 @@ impl Voice { if frames_available == 0 { // TODO: - ::std::old_io::timer::sleep(::std::time::duration::Duration::milliseconds(1)); + ::std::thread::sleep(::std::time::duration::Duration::milliseconds(1)); continue; } @@ -267,7 +267,7 @@ fn init() -> Result { fn check_result(result: winapi::HRESULT) -> Result<(), String> { if result < 0 { - return Err(::std::os::error_string(result)); // TODO: + return Err(format!("Error in winapi call")); // TODO: } Ok(())