From 930e3e5c4a8b2304ed3799424a52570dc24fc662 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 31 Jan 2008 17:18:46 +0000 Subject: [PATCH] gst-libs/gst/app/gstappsink.c: Really clean up the queue instead of just unreffing all buffers in it. Original commit message from CVS: * gst-libs/gst/app/gstappsink.c: (gst_app_sink_dispose): Really clean up the queue instead of just unreffing all buffers in it. * gst-libs/gst/app/gstappsrc.c: (gst_app_src_base_init), (gst_app_src_class_init), (gst_app_src_init), (gst_app_src_dispose), (gst_app_src_finalize): Fix dispose/finalize. --- ChangeLog | 11 +++++++++ gst-libs/gst/app/gstappsink.c | 6 ++++- gst-libs/gst/app/gstappsrc.c | 44 ++++++++++++++++++----------------- 3 files changed, 39 insertions(+), 22 deletions(-) diff --git a/ChangeLog b/ChangeLog index 255b76e77b..0fbc9dc457 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2008-01-31 Wim Taymans + + * gst-libs/gst/app/gstappsink.c: (gst_app_sink_dispose): + Really clean up the queue instead of just unreffing all buffers + in it. + + * gst-libs/gst/app/gstappsrc.c: (gst_app_src_base_init), + (gst_app_src_class_init), (gst_app_src_init), + (gst_app_src_dispose), (gst_app_src_finalize): + Fix dispose/finalize. + 2008-01-31 Jan Schmidt * ext/faad/gstfaad.c: (gst_faad_chanpos_to_gst): diff --git a/gst-libs/gst/app/gstappsink.c b/gst-libs/gst/app/gstappsink.c index 579a7afd33..d727efcfb9 100644 --- a/gst-libs/gst/app/gstappsink.c +++ b/gst-libs/gst/app/gstappsink.c @@ -232,6 +232,7 @@ static void gst_app_sink_dispose (GObject * obj) { GstAppSink *appsink = GST_APP_SINK (obj); + GstBuffer *buffer; if (appsink->caps) { gst_caps_unref (appsink->caps); @@ -241,7 +242,10 @@ gst_app_sink_dispose (GObject * obj) gst_buffer_unref (appsink->preroll); appsink->preroll = NULL; } - g_queue_foreach (appsink->queue, (GFunc) gst_mini_object_unref, NULL); + g_mutex_lock (appsink->mutex); + while ((buffer = g_queue_pop_head (appsink->queue))) + gst_buffer_unref (buffer); + g_mutex_unlock (appsink->mutex); G_OBJECT_CLASS (parent_class)->dispose (obj); } diff --git a/gst-libs/gst/app/gstappsrc.c b/gst-libs/gst/app/gstappsrc.c index 65e4c8c82d..a3e52af406 100644 --- a/gst-libs/gst/app/gstappsrc.c +++ b/gst-libs/gst/app/gstappsrc.c @@ -48,11 +48,14 @@ GST_STATIC_PAD_TEMPLATE ("src", GST_PAD_ALWAYS, GST_STATIC_CAPS_ANY); +static void gst_app_src_dispose (GObject * object); +static void gst_app_src_finalize (GObject * object); + static void gst_app_src_set_property (GObject * object, guint prop_id, const GValue * value, GParamSpec * pspec); static void gst_app_src_get_property (GObject * object, guint prop_id, GValue * value, GParamSpec * pspec); -static void gst_app_src_dispose (GObject * object); + static GstFlowReturn gst_app_src_create (GstPushSrc * psrc, GstBuffer ** buf); static gboolean gst_app_src_start (GstBaseSrc * psrc); static gboolean gst_app_src_stop (GstBaseSrc * psrc); @@ -65,15 +68,12 @@ gst_app_src_base_init (gpointer g_class) { GstElementClass *element_class = GST_ELEMENT_CLASS (g_class); - //GObjectClass *gobject_class = G_OBJECT_CLASS (g_class); - GST_DEBUG_CATEGORY_INIT (app_src_debug, "appsrc", 0, "appsrc element"); gst_element_class_set_details (element_class, &app_src_details); gst_element_class_add_pad_template (element_class, gst_static_pad_template_get (&gst_app_src_template)); - } static void @@ -83,9 +83,11 @@ gst_app_src_class_init (GstAppSrcClass * klass) GstPushSrcClass *pushsrc_class = (GstPushSrcClass *) klass; GstBaseSrcClass *basesrc_class = (GstBaseSrcClass *) klass; + gobject_class->dispose = gst_app_src_dispose; + gobject_class->finalize = gst_app_src_finalize; + gobject_class->set_property = gst_app_src_set_property; gobject_class->get_property = gst_app_src_get_property; - gobject_class->dispose = gst_app_src_dispose; pushsrc_class->create = gst_app_src_create; basesrc_class->start = gst_app_src_start; @@ -93,6 +95,14 @@ gst_app_src_class_init (GstAppSrcClass * klass) basesrc_class->unlock = gst_app_src_unlock; } +static void +gst_app_src_init (GstAppSrc * appsrc, GstAppSrcClass * klass) +{ + appsrc->mutex = g_mutex_new (); + appsrc->cond = g_cond_new (); + appsrc->queue = g_queue_new (); +} + static void gst_app_src_dispose (GObject * obj) { @@ -102,28 +112,20 @@ gst_app_src_dispose (GObject * obj) gst_caps_unref (appsrc->caps); appsrc->caps = NULL; } - if (appsrc->mutex) { - g_mutex_free (appsrc->mutex); - appsrc->mutex = NULL; - } - if (appsrc->cond) { - g_cond_free (appsrc->cond); - appsrc->cond = NULL; - } - if (appsrc->queue) { - g_queue_free (appsrc->queue); - appsrc->queue = NULL; - } G_OBJECT_CLASS (parent_class)->dispose (obj); } static void -gst_app_src_init (GstAppSrc * appsrc, GstAppSrcClass * klass) +gst_app_src_finalize (GObject * obj) { - appsrc->mutex = g_mutex_new (); - appsrc->cond = g_cond_new (); - appsrc->queue = g_queue_new (); + GstAppSrc *appsrc = GST_APP_SRC (obj); + + g_mutex_free (appsrc->mutex); + g_cond_free (appsrc->cond); + g_queue_free (appsrc->queue); + + G_OBJECT_CLASS (parent_class)->finalize (obj); } static void