summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorwm4 <wm4@mplayer2.org>2012-01-14 09:06:16 +0100
committerwm4 <wm4@mplayer2.org>2012-01-18 04:21:46 +0100
commit7187b4914838a302df78aa16c7a80b498f2be51a (patch)
tree9ec58f3b679e4e56b797a42a8c7bd49cdfcde83d
parentad18a33f5876be0c791bc394348a8333c50317b5 (diff)
downloadmpv-7187b4914838a302df78aa16c7a80b498f2be51a.tar.bz2
mpv-7187b4914838a302df78aa16c7a80b498f2be51a.tar.xz
af: fix crash when trying to use volume controls with AC3 pass-through
Changing the volume when softvol is enabled or if the audio output driver doesn't support volume controls causes insertion of the "volume" filter. This fails with AC3. Since the filter wasn't removed after that, and the filter chain was in a bogus state, random crashes occured past this point. Fix it by reinitializing the filter chain completely on failure. Volume controls simply won't work. (This can't be fixed, because AC3 is a compressed format, and would require additional decoding/encoding passes in order to support arbitrary volume changes.) This also affects balance controls.
-rw-r--r--libaf/af.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/libaf/af.c b/libaf/af.c
index 82a7d7398b..e4015727ac 100644
--- a/libaf/af.c
+++ b/libaf/af.c
@@ -278,6 +278,11 @@ static void af_print_filter_chain(af_stream_t* s)
mp_msg(MSGT_AFILTER, MSGL_V, "\n");
}
+// Warning:
+// A failed af_reinit() leaves the audio chain behind in a useless, broken
+// state (for example, format filters that were tentatively inserted stay
+// inserted).
+// In that case, you should always rebuild the filter chain, or abort.
int af_reinit(af_stream_t* s, af_instance_t* af)
{
do{
@@ -587,7 +592,9 @@ af_instance_t* af_add(af_stream_t* s, char* name){
// Reinitalize the filter list
if(AF_OK != af_reinit(s, s->first) ||
AF_OK != fixup_output_format(s)){
- free(new);
+ while (s->first)
+ af_remove(s, s->first);
+ af_init(s);
return NULL;
}
return new;