aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-16 18:52:01 +0100
committerMax Kellermann <max@duempel.org>2009-01-16 18:52:01 +0100
commit953b258e5eb8e93adb13046c5ae8a61934d35f61 (patch)
tree92440c565cbcf52e7b2a930c8d031b74db49971c /src
parent285a741b27a98dadaeb970c1f022c810245749f1 (diff)
downloadmpd-953b258e5eb8e93adb13046c5ae8a61934d35f61.tar.gz
mpd-953b258e5eb8e93adb13046c5ae8a61934d35f61.tar.xz
mpd-953b258e5eb8e93adb13046c5ae8a61934d35f61.zip
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.c14
1 files changed, 8 insertions, 6 deletions
diff --git a/src/pcm_resample_fallback.c b/src/pcm_resample_fallback.c
index dedb2eabc..c7789d69c 100644
--- a/src/pcm_resample_fallback.c
+++ b/src/pcm_resample_fallback.c
@@ -37,9 +37,10 @@ pcm_resample_16(struct pcm_resample_state *state,
size_t *dest_size_r)
{
unsigned src_pos, dest_pos = 0;
- unsigned src_samples = src_size / sizeof(*src_buffer);
- unsigned dest_samples =
- (src_samples * dest_rate + src_rate - 1) / src_rate;
+ unsigned src_frames = src_size / channels / sizeof(*src_buffer);
+ unsigned dest_frames =
+ (src_frames * dest_rate + src_rate - 1) / src_rate;
+ unsigned dest_samples = dest_frames * channels;
size_t dest_size = dest_samples * sizeof(*src_buffer);
int16_t *dest_buffer = pcm_buffer_get(&state->buffer, dest_size);
@@ -77,9 +78,10 @@ pcm_resample_24(struct pcm_resample_state *state,
size_t *dest_size_r)
{
unsigned src_pos, dest_pos = 0;
- unsigned src_samples = src_size / sizeof(*src_buffer);
- unsigned dest_samples =
- (src_samples * dest_rate + src_rate - 1) / src_rate;
+ unsigned src_frames = src_size / channels / sizeof(*src_buffer);
+ unsigned dest_frames =
+ (src_frames * dest_rate + src_rate - 1) / src_rate;
+ unsigned dest_samples = dest_frames * channels;
size_t dest_size = dest_samples * sizeof(*src_buffer);
int32_t *dest_buffer = pcm_buffer_get(&state->buffer, dest_size);