From 0d9d82a932d7fc022bfc410e206fb8edb6f3db03 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Wed, 24 Dec 2008 03:08:39 +0100 Subject: pcm_utils: check pcm_convert()==0 It is illegal to pass an empty audio buffer around. pcm_resample() sometimes seems to result in 0 samples, maybe related to libsamplerate. To work around that problem, add special checks after both pcm_convert() invocations. Removed the pcm_resample()==0 checks from pcm_convert(). --- src/output_thread.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) (limited to 'src/output_thread.c') diff --git a/src/output_thread.c b/src/output_thread.c index b65a601a3..c887828bb 100644 --- a/src/output_thread.c +++ b/src/output_thread.c @@ -69,9 +69,17 @@ static void ao_play(struct audio_output *ao) assert(size > 0); - if (!audio_format_equals(&ao->inAudioFormat, &ao->outAudioFormat)) + if (!audio_format_equals(&ao->inAudioFormat, &ao->outAudioFormat)) { convertAudioFormat(ao, &data, &size); + /* under certain circumstances, pcm_convert() may + return an empty buffer - this condition should be + investigated further, but for now, do this check as + a workaround: */ + if (size == 0) + return; + } + ret = ao->plugin->play(ao->data, data, size); if (!ret) { ao->plugin->cancel(ao->data); -- cgit v1.2.3