From 77c0003ad80a5e853e50edb473c5346267b00997 Mon Sep 17 00:00:00 2001 From: Michael Smith Date: Wed, 16 Nov 2005 18:09:15 +0000 Subject: [PATCH] Don't leak collectpads from oggmux. Original commit message from CVS: Don't leak collectpads from oggmux. --- ChangeLog | 10 ++++++++++ ext/ogg/gstoggmux.c | 24 +++++++++++++++++++----- 2 files changed, 29 insertions(+), 5 deletions(-) diff --git a/ChangeLog b/ChangeLog index ec867d9cc..88a60b508 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2005-11-16 Michael Smith + + * 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 * gst/videorate/gstvideorate.c: (gst_videorate_blank_data), diff --git a/ext/ogg/gstoggmux.c b/ext/ogg/gstoggmux.c index b8ce37cb5..79e14a7e9 100644 --- a/ext/ogg/gstoggmux.c +++ b/ext/ogg/gstoggmux.c @@ -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; -- 2.34.1