From fa510bd00cc62646255123504b3bfd4fc491f6bc Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 26 Oct 2015 15:51:26 +0100 Subject: af: prevent endless loop when removing filters due to spdif This code removes filters which can not take spdif inout. This was made so that PCM filters are transparently dropped in spdif mode. This entered an endless loop with: --af=lavcac3enc:::2 --audio-channels=5.1 The forced number of output channels is incompatible with spdif. It's trying to insert af_lavrresample as conversion filter to compensate for it. Of course this doesn't work, which triggers the PCM filter removal. Then it goes on normally - since the new state is exactly as before, it will try the same thing again, forever. Fix by reusing the retry counter, which is a very dumb but very effective measure against these cases of filter negotiation failure. We could try to be more clever (for example, if the removed filter is a conversion filter, we can be sure this won't work, and error out immediately). But better keep it simple and robust. --- audio/filter/af.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'audio') diff --git a/audio/filter/af.c b/audio/filter/af.c index 62ba6a9665..7ff3b49ae8 100644 --- a/audio/filter/af.c +++ b/audio/filter/af.c @@ -461,7 +461,8 @@ static int af_reinit(struct af_stream *s) struct af_instance *aft = af->prev; af_remove(s, af); af = aft->next; - break; + retry++; + continue; } } goto negotiate_error; -- cgit v1.2.3