Add some formats-related functions

This commit is contained in:
Pierre Krieger 2014-12-11 19:07:58 +01:00
parent 0bdafdab9b
commit 99c23327d8
3 changed files with 40 additions and 0 deletions

View file

@ -10,6 +10,8 @@ pub struct Channel {
max_frames_in_buffer: winapi::UINT32,
num_channels: winapi::WORD,
bytes_per_frame: winapi::WORD,
samples_per_second: winapi::DWORD,
bits_per_sample: winapi::WORD,
started: bool,
}
@ -30,6 +32,17 @@ impl Channel {
self.num_channels as ::ChannelsCount
}
pub fn get_samples_per_second(&self) -> u32 {
self.samples_per_second as u32
}
pub fn get_samples_format(&self) -> ::SampleFormat {
match self.bits_per_sample {
16 => ::SampleFormat::U16,
_ => unimplemented!(),
}
}
pub fn append_data<'a>(&'a mut self) -> Buffer<'a> {
unsafe {
loop {
@ -202,6 +215,8 @@ fn init() -> Result<Channel, String> {
max_frames_in_buffer: max_frames_in_buffer,
num_channels: format.nChannels,
bytes_per_frame: format.nBlockAlign,
samples_per_second: format.nSamplesPerSec,
bits_per_sample: format.wBitsPerSample,
started: false,
})
}