From 5b11d5a3320a037d715ab292020666fea0ed3993 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Mon, 8 Dec 2008 08:58:27 +0100 Subject: 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. --- src/pcm_utils.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/pcm_utils.c') 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; -- cgit v1.2.3