From 6c7173c54f13523bd8c9544274ad72b1a785b758 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Fri, 16 Jan 2009 18:46:34 +0100 Subject: pcm_resample_fallback: corrected the sample calculation Due to rounding errors, it was possible that the fallback resampler returned partial frames. --- src/pcm_resample_fallback.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'src') diff --git a/src/pcm_resample_fallback.c b/src/pcm_resample_fallback.c index a55efb824..cd0f9a799 100644 --- a/src/pcm_resample_fallback.c +++ b/src/pcm_resample_fallback.c @@ -32,7 +32,8 @@ pcm_resample_16(uint8_t channels, G_GNUC_UNUSED struct pcm_resample_state *state) { unsigned src_pos, dest_pos = 0; - unsigned dest_samples = dest_size / sizeof(*dest_buffer); + unsigned dest_frames = dest_size / channels / sizeof(*dest_buffer); + unsigned dest_samples = dest_frames * channels; assert((src_size % (sizeof(*src_buffer) * channels)) == 0); assert((dest_size % (sizeof(*dest_buffer) * channels)) == 0); @@ -68,7 +69,8 @@ pcm_resample_24(uint8_t channels, G_GNUC_UNUSED struct pcm_resample_state *state) { unsigned src_pos, dest_pos = 0; - unsigned dest_samples = dest_size / sizeof(*dest_buffer); + unsigned dest_frames = dest_size / channels / sizeof(*dest_buffer); + unsigned dest_samples = dest_frames * channels; switch (channels) { case 1: -- cgit v1.2.3