splitmuxsink: do not destroy the multiqueue & muxer when going to NULL
authorGeorge Kiagiadakis <george.kiagiadakis@collabora.com>
Sat, 24 Oct 2015 21:57:29 +0000 (23:57 +0200)
committerJan Schmidt <jan@centricular.com>
Wed, 28 Oct 2015 11:41:06 +0000 (22:41 +1100)
Instead, delay it until all request pads have been released. This is
because the release_pad() vfunc requires the multiqueue and muxer to
be there in order to release their request pads as well. If those
elements are destroyed earlier, release_pad() does not work, no
pads are released and some resources are leaked.

https://bugzilla.gnome.org/show_bug.cgi?id=753622

gst/multifile/gstsplitmuxsink.c

index b3da76d..aef9e64 100644 (file)
@@ -1321,6 +1321,10 @@ gst_splitmux_sink_release_pad (GstElement * element, GstPad * pad)
 
   gst_element_remove_pad (element, pad);
 
+  /* Reset the internal elements only after all request pads are released */
+  if (splitmux->contexts == NULL)
+    gst_splitmux_reset (splitmux);
+
 fail:
   GST_SPLITMUX_UNLOCK (splitmux);
 }
@@ -1554,7 +1558,9 @@ gst_splitmux_sink_change_state (GstElement * element, GstStateChange transition)
     case GST_STATE_CHANGE_READY_TO_NULL:
       GST_SPLITMUX_LOCK (splitmux);
       splitmux->fragment_id = 0;
-      gst_splitmux_reset (splitmux);
+      /* Reset internal elements only if no pad contexts are using them */
+      if (splitmux->contexts == NULL)
+        gst_splitmux_reset (splitmux);
       GST_SPLITMUX_UNLOCK (splitmux);
       break;
     default: