Don't leak collectpads from oggmux.

Original commit message from CVS:
Don't leak collectpads from oggmux.
This commit is contained in:
Michael Smith 2005-11-16 18:09:15 +00:00
parent a780198451
commit 77c0003ad8
2 changed files with 29 additions and 5 deletions

View file

@ -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> 2005-11-16 Edward Hervey <edward@fluendo.com>
* gst/videorate/gstvideorate.c: (gst_videorate_blank_data), * gst/videorate/gstvideorate.c: (gst_videorate_blank_data),

View file

@ -264,15 +264,26 @@ gst_ogg_mux_get_sink_event_masks (GstPad * pad)
static void static void
gst_ogg_mux_clear (GstOggMux * ogg_mux) 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->pulling = NULL;
ogg_mux->need_headers = TRUE; ogg_mux->need_headers = TRUE;
ogg_mux->max_delay = DEFAULT_MAX_DELAY; ogg_mux->max_delay = DEFAULT_MAX_DELAY;
ogg_mux->max_page_delay = DEFAULT_MAX_PAGE_DELAY; ogg_mux->max_page_delay = DEFAULT_MAX_PAGE_DELAY;
ogg_mux->delta_pad = NULL; 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 static void
@ -291,6 +302,8 @@ gst_ogg_mux_init (GstOggMux * ogg_mux)
/* seed random number generator for creation of serial numbers */ /* seed random number generator for creation of serial numbers */
srand (time (NULL)); srand (time (NULL));
ogg_mux->collect = NULL;
gst_ogg_mux_clear (ogg_mux); gst_ogg_mux_clear (ogg_mux);
} }
@ -1369,6 +1382,7 @@ gst_ogg_mux_change_state (GstElement * element, GstStateChange transition)
switch (transition) { switch (transition) {
case GST_STATE_CHANGE_NULL_TO_READY: case GST_STATE_CHANGE_NULL_TO_READY:
gst_ogg_mux_reset (ogg_mux);
break; break;
case GST_STATE_CHANGE_READY_TO_PAUSED: case GST_STATE_CHANGE_READY_TO_PAUSED:
ogg_mux->next_ts = 0; 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: case GST_STATE_CHANGE_PAUSED_TO_READY:
gst_collectpads_stop (ogg_mux->collect); gst_collectpads_stop (ogg_mux->collect);
gst_ogg_mux_clear_collectpads (ogg_mux->collect); gst_ogg_mux_clear_collectpads (ogg_mux->collect);
gst_ogg_mux_clear (ogg_mux);
break; break;
case GST_STATE_CHANGE_READY_TO_NULL: case GST_STATE_CHANGE_READY_TO_NULL:
gst_ogg_mux_clear (ogg_mux);
break; break;
default: default:
break; break;