mirror of https://github.com/mpv-player/mpv
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.
This commit is contained in:
parent
61afe3820a
commit
e246c3f060
|
@ -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
|
// First try if we can change the output format of the previous
|
||||||
// filter to the input format the current filter is expecting.
|
// filter to the input format the current filter is expecting.
|
||||||
struct mp_audio in = af->fmt_in;
|
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
|
// This should have been successful (because it succeeded
|
||||||
// before), even if just reverting to the old output format.
|
// before), even if just reverting to the old output format.
|
||||||
mp_audio_copy_config(af->data, &in);
|
mp_audio_copy_config(af->prev->data, &in);
|
||||||
if (filter_reinit(af->prev) != AF_OK)
|
rv = filter_reinit(af->prev);
|
||||||
return AF_ERROR;
|
if (rv != AF_OK)
|
||||||
|
return rv;
|
||||||
}
|
}
|
||||||
if (!mp_audio_config_equals(af->prev->data, &in)) {
|
if (!mp_audio_config_equals(af->prev->data, &in)) {
|
||||||
// Retry with conversion filter added.
|
// Retry with conversion filter added.
|
||||||
|
|
Loading…
Reference in New Issue