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.
This commit is contained in:
Max Kellermann 2008-12-08 08:58:27 +01:00
parent 0128a9e910
commit 5b11d5a332

View File

@ -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;