diff options
author | Max Kellermann <max@duempel.org> | 2009-01-16 18:46:34 +0100 |
---|---|---|
committer | Max Kellermann <max@duempel.org> | 2009-01-16 18:46:34 +0100 |
commit | 6c7173c54f13523bd8c9544274ad72b1a785b758 (patch) | |
tree | 2fa95f8ca0c63f2b71c049155730e9db5b2f28be /src | |
parent | 33b5693a12ed53aff623643ab67704d1e9c74990 (diff) |
pcm_resample_fallback: corrected the sample calculation
Due to rounding errors, it was possible that the fallback resampler
returned partial frames.
Diffstat (limited to 'src')
-rw-r--r-- | src/pcm_resample_fallback.c | 6 |
1 files changed, 4 insertions, 2 deletions
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: |