aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMax Kellermann <max@duempel.org>2008-12-08 08:58:27 +0100
committerMax Kellermann <max@duempel.org>2008-12-08 08:58:27 +0100
commit5b11d5a3320a037d715ab292020666fea0ed3993 (patch)
tree4ac8858c10452777e6187ed29a9a53e11aeacd5e /src
parent0128a9e91025c6d6dea145dabfa447150f8d9916 (diff)
downloadmpd-5b11d5a3320a037d715ab292020666fea0ed3993.tar.gz
mpd-5b11d5a3320a037d715ab292020666fea0ed3993.tar.xz
mpd-5b11d5a3320a037d715ab292020666fea0ed3993.zip
pcm_utils: always round up resampling buffer size
libsamplerate produces cracks in the sound output when the destination buffer is too small. This is the case when pcm_convert_size() rounds down. Use ceil(x) instead of floor(0.5+x) there to prevent a buffer overrun.
Diffstat (limited to 'src')
-rw-r--r--src/pcm_utils.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/src/pcm_utils.c b/src/pcm_utils.c
index 4759c20ac..2fb5f6c3f 100644
--- a/src/pcm_utils.c
+++ b/src/pcm_utils.c
@@ -461,7 +461,7 @@ size_t pcm_convert_size(const struct audio_format *inFormat, size_t src_size,
assert((src_size % audio_format_frame_size(inFormat)) == 0);
dest_size /= audio_format_frame_size(inFormat);
- dest_size = floor(0.5 + (double)dest_size * ratio);
+ dest_size = ceil((double)dest_size * ratio);
dest_size *= audio_format_frame_size(outFormat);
return dest_size;