Fix PCM formats conversions not working

This commit is contained in:
Pierre Krieger 2014-12-15 16:40:55 +01:00
parent 49636365d8
commit d06a67a97b
1 changed files with 9 additions and 1 deletions

View File

@ -137,6 +137,10 @@ impl Channel {
if samples_rate != target_samples_rate || channels != target_channels ||
source_samples_format != target_samples_format
{
let max_elements = max_elements * target_channels as uint / channels as uint;
let max_elements = max_elements * target_samples_rate.0 as uint / samples_rate.0 as uint;
// TODO: samples format
let mut target_buffer = self.0.append_data(max_elements);
// computing the length of the intermediary buffer
@ -178,9 +182,13 @@ impl<'a, T> Deref<[T]> for Buffer<'a, T> {
impl<'a, T> DerefMut<[T]> for Buffer<'a, T> {
fn deref_mut(&mut self) -> &mut [T] {
if let Some(ref mut conversion) = self.conversion {
conversion.intermediate_buffer.as_mut_slice()
} else {
self.target.as_mut().unwrap().get_buffer()
}
}
}
#[unsafe_destructor]
impl<'a, T> Drop for Buffer<'a, T> where T: Sample {