From 04f9aac2c33eaac24807a2c79b631eafb5d030b1 Mon Sep 17 00:00:00 2001 From: Pierre Krieger Date: Wed, 17 Dec 2014 09:16:26 +0100 Subject: [PATCH] Rename `Channel` to `Voice` --- examples/beep.rs | 2 +- examples/music.rs | 2 +- src/alsa/mod.rs | 12 ++++++------ src/lib.rs | 14 +++++++------- src/wasapi/mod.rs | 12 ++++++------ 5 files changed, 21 insertions(+), 21 deletions(-) diff --git a/examples/beep.rs b/examples/beep.rs index 10fcc09..e74120a 100644 --- a/examples/beep.rs +++ b/examples/beep.rs @@ -1,7 +1,7 @@ extern crate cpal; fn main() { - let mut channel = cpal::Channel::new(); + let mut channel = cpal::Voice::new(); // producing a sinusoid let mut data_source = diff --git a/examples/music.rs b/examples/music.rs index af5cc87..34006ce 100644 --- a/examples/music.rs +++ b/examples/music.rs @@ -4,7 +4,7 @@ extern crate vorbis; use std::io::BufReader; fn main() { - let mut channel = cpal::Channel::new(); + let mut channel = cpal::Voice::new(); let mut decoder = vorbis::Decoder::new(BufReader::new(include_bin!("music.ogg"))) .unwrap(); diff --git a/src/alsa/mod.rs b/src/alsa/mod.rs index 4dddd88..40450b5 100644 --- a/src/alsa/mod.rs +++ b/src/alsa/mod.rs @@ -3,18 +3,18 @@ extern crate libc; use std::{mem, ptr}; -pub struct Channel { +pub struct Voice { channel: *mut alsa::snd_pcm_t, num_channels: u16, } pub struct Buffer<'a, T> { - channel: &'a mut Channel, + channel: &'a mut Voice, buffer: Vec, } -impl Channel { - pub fn new() -> Channel { +impl Voice { + pub fn new() -> Voice { unsafe { let name = "default".to_c_str(); @@ -33,7 +33,7 @@ impl Channel { check_errors(alsa::snd_pcm_prepare(playback_handle)).unwrap(); - Channel { + Voice { channel: playback_handle, num_channels: 2, } @@ -65,7 +65,7 @@ impl Channel { } } -impl Drop for Channel { +impl Drop for Voice { fn drop(&mut self) { unsafe { alsa::snd_pcm_close(self.channel); diff --git a/src/lib.rs b/src/lib.rs index c5337b8..4cf3e35 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -19,11 +19,11 @@ mod cpal_impl; /// Controls a sound output. /// -/// Create one `Channel` for each sound that you want to play. +/// Create one `Voice` for each sound that you want to play. /// -/// A channel must be periodically filled with new data by calling `append_data`, or the sound +/// A voice must be periodically filled with new data by calling `append_data`, or the sound /// will stop playing. -pub struct Channel(cpal_impl::Channel); +pub struct Voice(cpal_impl::Voice); /// Number of channels. pub type ChannelsCount = u16; @@ -52,11 +52,11 @@ struct RequiredConversion { to_channels: ChannelsCount, } -impl Channel { +impl Voice { /// Builds a new channel. - pub fn new() -> Channel { - let channel = cpal_impl::Channel::new(); - Channel(channel) + pub fn new() -> Voice { + let channel = cpal_impl::Voice::new(); + Voice(channel) } /// Returns the number of channels. diff --git a/src/wasapi/mod.rs b/src/wasapi/mod.rs index 8ee1530..f522e99 100644 --- a/src/wasapi/mod.rs +++ b/src/wasapi/mod.rs @@ -5,7 +5,7 @@ use std::{mem, ptr}; use std::c_vec::CVec; // TODO: determine if should be NoSend or not -pub struct Channel { +pub struct Voice { audio_client: *mut winapi::IAudioClient, render_client: *mut winapi::IAudioRenderClient, max_frames_in_buffer: winapi::UINT32, @@ -24,8 +24,8 @@ pub struct Buffer<'a, T> { start_on_drop: bool, } -impl Channel { - pub fn new() -> Channel { +impl Voice { + pub fn new() -> Voice { init().unwrap() } @@ -97,7 +97,7 @@ impl Channel { } } -impl Drop for Channel { +impl Drop for Voice { fn drop(&mut self) { unsafe { { @@ -134,7 +134,7 @@ impl<'a, T> Buffer<'a, T> { } } -fn init() -> Result { +fn init() -> Result { // FIXME: release everything unsafe { try!(check_result(winapi::CoInitializeEx(::std::ptr::null_mut(), 0))); @@ -229,7 +229,7 @@ fn init() -> Result { render_client.as_mut().unwrap() }; - Ok(Channel { + Ok(Voice { audio_client: audio_client, render_client: render_client, max_frames_in_buffer: max_frames_in_buffer,