From d1778e3f6dc564b4e360f530f920c83673b70145 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Sebastian=20Dr=C3=B6ge?= Date: Thu, 1 Feb 2007 17:52:39 +0000 Subject: [PATCH] ext/ogg/gstoggmux.c: Use newly added GstCollectPads API to free the allocated resources in the GstOggPad structures (... Original commit message from CVS: reviewed by: Wim Taymans * ext/ogg/gstoggmux.c: (gst_ogg_mux_ogg_pad_destroy_notify), (gst_ogg_mux_request_new_pad), (gst_ogg_mux_release_pad): Use newly added GstCollectPads API to free the allocated resources in the GstOggPad structures (#402393). --- ChangeLog | 9 +++++++++ ext/ogg/gstoggmux.c | 43 +++++++++++++++++++------------------------ 2 files changed, 28 insertions(+), 24 deletions(-) diff --git a/ChangeLog b/ChangeLog index bc5369f210..3373f8c338 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,12 @@ +2007-02-01 Sebastian Dröge + + reviewed by: Wim Taymans + + * ext/ogg/gstoggmux.c: (gst_ogg_mux_ogg_pad_destroy_notify), + (gst_ogg_mux_request_new_pad), (gst_ogg_mux_release_pad): + Use newly added GstCollectPads API to free the allocated resources in + the GstOggPad structures (#402393). + 2007-01-31 Jan Schmidt * gst/playback/gstplaybin.c: (gen_vis_element): diff --git a/ext/ogg/gstoggmux.c b/ext/ogg/gstoggmux.c index fda40a7c23..c941915c97 100644 --- a/ext/ogg/gstoggmux.c +++ b/ext/ogg/gstoggmux.c @@ -344,6 +344,23 @@ gst_ogg_mux_finalize (GObject * object) G_OBJECT_CLASS (parent_class)->finalize (object); } +static void +gst_ogg_mux_ogg_pad_destroy_notify (GstCollectData * data) +{ + GstOggPad *oggpad = (GstOggPad *) data; + GstBuffer *buf; + + ogg_stream_clear (&oggpad->stream); + + if (oggpad->pagebuffers) { + while ((buf = g_queue_pop_head (oggpad->pagebuffers)) != NULL) { + gst_buffer_unref (buf); + } + g_queue_free (oggpad->pagebuffers); + oggpad->pagebuffers = NULL; + } +} + static GstPadLinkReturn gst_ogg_mux_sinkconnect (GstPad * pad, GstPad * peer) { @@ -401,8 +418,8 @@ gst_ogg_mux_request_new_pad (GstElement * element, GstOggPad *oggpad; oggpad = (GstOggPad *) - gst_collect_pads_add_pad (ogg_mux->collect, newpad, - sizeof (GstOggPad)); + gst_collect_pads_add_pad_full (ogg_mux->collect, newpad, + sizeof (GstOggPad), gst_ogg_mux_ogg_pad_destroy_notify); ogg_mux->active_pads++; oggpad->serial = serial; @@ -443,31 +460,9 @@ static void gst_ogg_mux_release_pad (GstElement * element, GstPad * pad) { GstOggMux *ogg_mux; - GSList *walk; ogg_mux = GST_OGG_MUX (gst_pad_get_parent (pad)); - /* Find out GstOggPad in the collect pads info and clean it up */ - - GST_OBJECT_LOCK (ogg_mux->collect); - for (walk = ogg_mux->collect->data; walk; walk = g_slist_next (walk)) { - GstOggPad *oggpad = (GstOggPad *) walk->data; - GstCollectData *cdata = (GstCollectData *) walk->data; - GstBuffer *buf; - - if (cdata->pad == pad) { - ogg_stream_clear (&oggpad->stream); - - while ((buf = g_queue_pop_head (oggpad->pagebuffers)) != NULL) { - gst_buffer_unref (buf); - } - - g_queue_free (oggpad->pagebuffers); - oggpad->pagebuffers = NULL; - } - } - GST_OBJECT_UNLOCK (ogg_mux->collect); - gst_collect_pads_remove_pad (ogg_mux->collect, pad); gst_element_remove_pad (element, pad); } -- 2.34.1