From a636c39638e7d667d71ec5a1070c3e468cf45a73 Mon Sep 17 00:00:00 2001 From: "Jan Alexander Steffens (heftig)" Date: Tue, 13 Jan 2015 16:07:06 +0100 Subject: [PATCH] audioresample: Try to prevent endless looping Speex may decide not to consume any samples because it can't write any. I've seen a hang during draining caused by the resample loop never terminating. In that case, resampling happened as normal until olen was 0 but ilen was still 1. _process_native then reduced ichunk to 0, so ilen never decreased below 1 and the loop never terminated. Instead of reverting 684cf44 ({audioresample: don't skip input samples), break only if all output samples have been produced and speex refuses to consume any more input samples. https://bugzilla.gnome.org/show_bug.cgi?id=732908 --- gst/audioresample/resample.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/gst/audioresample/resample.c b/gst/audioresample/resample.c index d067192294..6364e19280 100644 --- a/gst/audioresample/resample.c +++ b/gst/audioresample/resample.c @@ -1200,6 +1200,8 @@ speex_resampler_process_float (SpeexResamplerState * st, out += ochunk * st->out_stride; if (in) in += ichunk * istride; + if (olen == 0 && ichunk == 0) + break; } } *in_len -= ilen; @@ -1280,6 +1282,8 @@ speex_resampler_process_int (SpeexResamplerState * st, out += (ochunk + omagic) * ostride_save; if (in) in += ichunk * istride_save; + if (olen == 0 && ichunk == 0) + break; } st->out_stride = ostride_save; *in_len -= ilen;