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
This commit is contained in:
Jan Alexander Steffens (heftig) 2015-01-13 16:07:06 +01:00 committed by Sebastian Dröge
parent 63afbce6be
commit a636c39638

View file

@ -1200,6 +1200,8 @@ speex_resampler_process_float (SpeexResamplerState * st,
out += ochunk * st->out_stride; out += ochunk * st->out_stride;
if (in) if (in)
in += ichunk * istride; in += ichunk * istride;
if (olen == 0 && ichunk == 0)
break;
} }
} }
*in_len -= ilen; *in_len -= ilen;
@ -1280,6 +1282,8 @@ speex_resampler_process_int (SpeexResamplerState * st,
out += (ochunk + omagic) * ostride_save; out += (ochunk + omagic) * ostride_save;
if (in) if (in)
in += ichunk * istride_save; in += ichunk * istride_save;
if (olen == 0 && ichunk == 0)
break;
} }
st->out_stride = ostride_save; st->out_stride = ostride_save;
*in_len -= ilen; *in_len -= ilen;