From e246c3f060513a9bcda6097f6ca6ddfba5bf3579 Mon Sep 17 00:00:00 2001 From: wm4 Date: Mon, 11 Jul 2016 12:23:25 +0200 Subject: audio: fix code for adjusting conversion filters This code was supposed to adjust existing conversion filters (to make them output a different format). But the code was just broken, apparently a refactoring accident. It accessed af instead of af->prev. The bug tended to add new conversion filters, even if an existing one could have been used. (Can be tested by inserting a dummy lavrresample filter followed by a format filter which forces conversion.) In addition, it's probably better to return the actual error code if reinitializing the filter fails. It would then respect an AF_FALSE return value, which means format negotiation failed, instead of a generic error. --- audio/filter/af.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/audio/filter/af.c b/audio/filter/af.c index 5706f73daa..8d1ce889c4 100644 --- a/audio/filter/af.c +++ b/audio/filter/af.c @@ -315,12 +315,13 @@ static int filter_reinit_with_conversion(struct af_stream *s, struct af_instance // First try if we can change the output format of the previous // filter to the input format the current filter is expecting. struct mp_audio in = af->fmt_in; - if (af->prev != s->first && !mp_audio_config_equals(af->data, &in)) { + if (af->prev != s->first && !mp_audio_config_equals(af->prev->data, &in)) { // This should have been successful (because it succeeded // before), even if just reverting to the old output format. - mp_audio_copy_config(af->data, &in); - if (filter_reinit(af->prev) != AF_OK) - return AF_ERROR; + mp_audio_copy_config(af->prev->data, &in); + rv = filter_reinit(af->prev); + if (rv != AF_OK) + return rv; } if (!mp_audio_config_equals(af->prev->data, &in)) { // Retry with conversion filter added. -- cgit v1.2.3