Rename `Channel` to `Voice`

This commit is contained in:
Pierre Krieger 2014-12-17 09:16:26 +01:00
parent 094dbef0e4
commit 04f9aac2c3
5 changed files with 21 additions and 21 deletions

View File

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

View File

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

View File

@ -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<T>,
}
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);

View File

@ -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<T> {
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.

View File

@ -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<Channel, String> {
fn init() -> Result<Voice, String> {
// FIXME: release everything
unsafe {
try!(check_result(winapi::CoInitializeEx(::std::ptr::null_mut(), 0)));
@ -229,7 +229,7 @@ fn init() -> Result<Channel, String> {
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,