aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2009-01-16 18:46:34 +0100
committerMax Kellermann <max@duempel.org>2009-01-16 18:46:34 +0100
commit6c7173c54f13523bd8c9544274ad72b1a785b758 (patch)
tree2fa95f8ca0c63f2b71c049155730e9db5b2f28be
parent33b5693a12ed53aff623643ab67704d1e9c74990 (diff)
downloadmpd-6c7173c54f13523bd8c9544274ad72b1a785b758.tar.gz
mpd-6c7173c54f13523bd8c9544274ad72b1a785b758.tar.xz
mpd-6c7173c54f13523bd8c9544274ad72b1a785b758.zip
pcm_resample_fallback: corrected the sample calculation
Due to rounding errors, it was possible that the fallback resampler returned partial frames.
-rw-r--r--NEWS1
-rw-r--r--src/pcm_resample_fallback.c6
2 files changed, 5 insertions, 2 deletions
diff --git a/NEWS b/NEWS
index ce65f7db7..bf15c228e 100644
--- a/NEWS
+++ b/NEWS
@@ -13,6 +13,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 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: