Fix PCM formats conversions not working
This commit is contained in:
parent
49636365d8
commit
d06a67a97b
|
@ -137,6 +137,10 @@ impl Channel {
|
||||||
if samples_rate != target_samples_rate || channels != target_channels ||
|
if samples_rate != target_samples_rate || channels != target_channels ||
|
||||||
source_samples_format != target_samples_format
|
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);
|
let mut target_buffer = self.0.append_data(max_elements);
|
||||||
|
|
||||||
// computing the length of the intermediary buffer
|
// 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> {
|
impl<'a, T> DerefMut<[T]> for Buffer<'a, T> {
|
||||||
fn deref_mut(&mut self) -> &mut [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()
|
self.target.as_mut().unwrap().get_buffer()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
#[unsafe_destructor]
|
#[unsafe_destructor]
|
||||||
impl<'a, T> Drop for Buffer<'a, T> where T: Sample {
|
impl<'a, T> Drop for Buffer<'a, T> where T: Sample {
|
||||||
|
|
Loading…
Reference in New Issue