[MPlayer-cvslog] r37077 - trunk/libaf/af.c

reimar subversion at mplayerhq.hu
Wed Mar 26 20:23:38 CET 2014


Author: reimar
Date: Wed Mar 26 20:23:38 2014
New Revision: 37077

Log:
Restore filter chain if af_add failed.

Fixes crashes when e.g. trying to change balance
with -ac hwac3.

Modified:
   trunk/libaf/af.c

Modified: trunk/libaf/af.c
==============================================================================
--- trunk/libaf/af.c	Wed Mar 26 17:59:16 2014	(r37076)
+++ trunk/libaf/af.c	Wed Mar 26 20:23:38 2014	(r37077)
@@ -542,11 +542,13 @@ int af_init(af_stream_t* s)
    If the filter couldn't be added the return value is NULL. */
 af_instance_t* af_add(af_stream_t* s, char* name){
   af_instance_t* new;
+  int first_is_format;
   // Sanity check
   if(!s || !s->first || !name)
     return NULL;
+  first_is_format = !strcmp(s->first->info->name,"format");
   // Insert the filter somewhere nice
-  if(!strcmp(s->first->info->name,"format"))
+  if(first_is_format)
     new = af_append(s, s->first, name);
   else
     new = af_prepend(s, s->first, name);
@@ -556,7 +558,17 @@ af_instance_t* af_add(af_stream_t* s, ch
   // Reinitalize the filter list
   if(AF_OK != af_reinit(s, s->first) ||
      AF_OK != fixup_output_format(s)){
-    free(new);
+    // remove auto-inserted filters
+    af_instance_t *to_remove = first_is_format ? s->first->next : s->first;
+    while (to_remove != new)
+    {
+        af_instance_t *next = to_remove->next;
+        af_remove(s, to_remove);
+        to_remove = next;
+    }
+    af_remove(s, new);
+    af_reinit(s, s->first);
+    fixup_output_format(s);
     return NULL;
   }
   return new;


More information about the MPlayer-cvslog mailing list