This commit is contained in:
Pierre Krieger 2015-03-25 11:21:10 +01:00
parent f7c2949549
commit 84326cb4a7
6 changed files with 12 additions and 14 deletions

View File

@ -1,7 +1,7 @@
[package]
name = "cpal"
version = "0.0.15"
version = "0.0.16"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
description = "Cross-platform audio playing library in pure Rust."
repository = "https://github.com/tomaka/cpal"

View File

@ -1,7 +1,7 @@
[package]
name = "alsa-sys"
version = "0.0.4"
version = "0.0.5"
authors = ["Pierre Krieger <pierre.krieger1708@gmail.com>"]
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"

View File

@ -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() {

View File

@ -19,7 +19,7 @@ pub fn convert_samples_rate<T>(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<T>(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);
}

View File

@ -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
}

View File

@ -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<Voice, String> {
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(())