Don't leak collectpads from oggmux.
authorMichael Smith <msmith@xiph.org>
Wed, 16 Nov 2005 18:09:15 +0000 (18:09 +0000)
committerMichael Smith <msmith@xiph.org>
Wed, 16 Nov 2005 18:09:15 +0000 (18:09 +0000)
Original commit message from CVS:
Don't leak collectpads from oggmux.

ChangeLog
ext/ogg/gstoggmux.c

index ec867d9ccc2222dc1b7c8308fb52f3fd2274d19f..88a60b50864a286bb9f6117a74468376695715fb 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2005-11-16  Michael Smith <msmith@fluendo.com>
+
+       * ext/ogg/gstoggmux.c: (gst_ogg_mux_clear), (gst_ogg_mux_reset),
+       (gst_ogg_mux_init), (gst_ogg_mux_request_new_pad),
+       (gst_ogg_mux_push_buffer), (gst_ogg_mux_dequeue_page),
+       (gst_ogg_mux_pad_queue_page), (gst_ogg_mux_queue_pads),
+       (gst_ogg_mux_collected), (gst_ogg_mux_clear_collectpads),
+       (gst_ogg_mux_change_state):
+         Fix leaking collectpads.
+
 2005-11-16  Edward Hervey  <edward@fluendo.com>
 
        * gst/videorate/gstvideorate.c: (gst_videorate_blank_data),
index b8ce37cb5ad9efd15722a1fd408d2176d01f174d..79e14a7e9ae488d307382970debf6f5e15a472d2 100644 (file)
@@ -264,15 +264,26 @@ gst_ogg_mux_get_sink_event_masks (GstPad * pad)
 static void
 gst_ogg_mux_clear (GstOggMux * ogg_mux)
 {
-  ogg_mux->collect = gst_collectpads_new ();
-  gst_collectpads_set_function (ogg_mux->collect,
-      (GstCollectPadsFunction) gst_ogg_mux_collected, ogg_mux);
   ogg_mux->pulling = NULL;
   ogg_mux->need_headers = TRUE;
   ogg_mux->max_delay = DEFAULT_MAX_DELAY;
   ogg_mux->max_page_delay = DEFAULT_MAX_PAGE_DELAY;
-
   ogg_mux->delta_pad = NULL;
+
+  if (ogg_mux->collect) {
+    gst_object_unref (ogg_mux->collect);
+    ogg_mux->collect = NULL;
+  }
+}
+
+static void
+gst_ogg_mux_reset (GstOggMux * ogg_mux)
+{
+  gst_ogg_mux_clear (ogg_mux);
+
+  ogg_mux->collect = gst_collectpads_new ();
+  gst_collectpads_set_function (ogg_mux->collect,
+      (GstCollectPadsFunction) gst_ogg_mux_collected, ogg_mux);
 }
 
 static void
@@ -291,6 +302,8 @@ gst_ogg_mux_init (GstOggMux * ogg_mux)
   /* seed random number generator for creation of serial numbers */
   srand (time (NULL));
 
+  ogg_mux->collect = NULL;
+
   gst_ogg_mux_clear (ogg_mux);
 }
 
@@ -1369,6 +1382,7 @@ gst_ogg_mux_change_state (GstElement * element, GstStateChange transition)
 
   switch (transition) {
     case GST_STATE_CHANGE_NULL_TO_READY:
+      gst_ogg_mux_reset (ogg_mux);
       break;
     case GST_STATE_CHANGE_READY_TO_PAUSED:
       ogg_mux->next_ts = 0;
@@ -1390,9 +1404,9 @@ gst_ogg_mux_change_state (GstElement * element, GstStateChange transition)
     case GST_STATE_CHANGE_PAUSED_TO_READY:
       gst_collectpads_stop (ogg_mux->collect);
       gst_ogg_mux_clear_collectpads (ogg_mux->collect);
-      gst_ogg_mux_clear (ogg_mux);
       break;
     case GST_STATE_CHANGE_READY_TO_NULL:
+      gst_ogg_mux_clear (ogg_mux);
       break;
     default:
       break;