aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--NEWS1
-rw-r--r--src/pcm_resample_fallback.c14
2 files changed, 9 insertions, 6 deletions
diff --git a/NEWS b/NEWS
index 30dec9980..cdeb78ed4 100644
--- a/NEWS
+++ b/NEWS
@@ -29,6 +29,7 @@ MPD 0.14.1 - not yet released
- honour http_proxy_* config directives
- fix assertion failure on "connection refused"
- fix assertion failure with empty HTTP responses
+* corrected the sample calculation in the fallback resampler
* log: automatically append newline
* fix setenv() conflict on Solaris
* configure.ac: check for pkg-config before using it
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);