From: Tim-Philipp Müller Date: Wed, 18 Jan 2012 17:21:36 +0000 (+0000) Subject: encoding: port to new GLib threading API X-Git-Tag: 1.19.3~511^2~6914 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=6b12cee5a8654cc0ae66aa07c061cba3964c3a93;p=platform%2Fupstream%2Fgstreamer.git encoding: port to new GLib threading API --- diff --git a/gst/encoding/gststreamcombiner.c b/gst/encoding/gststreamcombiner.c index 19a6adf..d49e083 100644 --- a/gst/encoding/gststreamcombiner.c +++ b/gst/encoding/gststreamcombiner.c @@ -38,10 +38,10 @@ GST_DEBUG_CATEGORY_STATIC (gst_stream_combiner_debug); G_DEFINE_TYPE (GstStreamCombiner, gst_stream_combiner, GST_TYPE_ELEMENT); -#define STREAMS_LOCK(obj) (g_mutex_lock(obj->lock)) -#define STREAMS_UNLOCK(obj) (g_mutex_unlock(obj->lock)) +#define STREAMS_LOCK(obj) (g_mutex_lock(&obj->lock)) +#define STREAMS_UNLOCK(obj) (g_mutex_unlock(&obj->lock)) -static void gst_stream_combiner_dispose (GObject * object); +static void gst_stream_combiner_finalize (GObject * object); static GstPad *gst_stream_combiner_request_new_pad (GstElement * element, GstPadTemplate * templ, const gchar * name, const GstCaps * caps); @@ -57,7 +57,7 @@ gst_stream_combiner_class_init (GstStreamCombinerClass * klass) gobject_klass = (GObjectClass *) klass; gstelement_klass = (GstElementClass *) klass; - gobject_klass->dispose = gst_stream_combiner_dispose; + gobject_klass->finalize = gst_stream_combiner_finalize; GST_DEBUG_CATEGORY_INIT (gst_stream_combiner_debug, "streamcombiner", 0, "Stream Combiner"); @@ -79,16 +79,13 @@ gst_stream_combiner_class_init (GstStreamCombinerClass * klass) } static void -gst_stream_combiner_dispose (GObject * object) +gst_stream_combiner_finalize (GObject * object) { GstStreamCombiner *stream_combiner = (GstStreamCombiner *) object; - if (stream_combiner->lock) { - g_mutex_free (stream_combiner->lock); - stream_combiner->lock = NULL; - } + g_mutex_clear (&stream_combiner->lock); - G_OBJECT_CLASS (gst_stream_combiner_parent_class)->dispose (object); + G_OBJECT_CLASS (gst_stream_combiner_parent_class)->finalize (object); } static GstFlowReturn @@ -199,7 +196,7 @@ gst_stream_combiner_init (GstStreamCombiner * stream_combiner) gst_stream_combiner_src_query); gst_element_add_pad (GST_ELEMENT (stream_combiner), stream_combiner->srcpad); - stream_combiner->lock = g_mutex_new (); + g_mutex_init (&stream_combiner->lock); } static GstPad * diff --git a/gst/encoding/gststreamcombiner.h b/gst/encoding/gststreamcombiner.h index ce67277..246d935 100644 --- a/gst/encoding/gststreamcombiner.h +++ b/gst/encoding/gststreamcombiner.h @@ -41,7 +41,7 @@ struct _GstStreamCombiner { * * the current pad * * the list of srcpads */ - GMutex *lock; + GMutex lock; /* Currently activated srcpad */ GstPad *current; GList *sinkpads; diff --git a/gst/encoding/gststreamsplitter.c b/gst/encoding/gststreamsplitter.c index d37f15e..3f58b04 100644 --- a/gst/encoding/gststreamsplitter.c +++ b/gst/encoding/gststreamsplitter.c @@ -38,10 +38,11 @@ GST_DEBUG_CATEGORY_STATIC (gst_stream_splitter_debug); G_DEFINE_TYPE (GstStreamSplitter, gst_stream_splitter, GST_TYPE_ELEMENT); -#define STREAMS_LOCK(obj) (g_mutex_lock(obj->lock)) -#define STREAMS_UNLOCK(obj) (g_mutex_unlock(obj->lock)) +#define STREAMS_LOCK(obj) (g_mutex_lock(&obj->lock)) +#define STREAMS_UNLOCK(obj) (g_mutex_unlock(&obj->lock)) static void gst_stream_splitter_dispose (GObject * object); +static void gst_stream_splitter_finalize (GObject * object); static gboolean gst_stream_splitter_sink_setcaps (GstPad * pad, GstCaps * caps); @@ -60,6 +61,7 @@ gst_stream_splitter_class_init (GstStreamSplitterClass * klass) gstelement_klass = (GstElementClass *) klass; gobject_klass->dispose = gst_stream_splitter_dispose; + gobject_klass->finalize = gst_stream_splitter_finalize; GST_DEBUG_CATEGORY_INIT (gst_stream_splitter_debug, "streamsplitter", 0, "Stream Splitter"); @@ -85,11 +87,6 @@ gst_stream_splitter_dispose (GObject * object) { GstStreamSplitter *stream_splitter = (GstStreamSplitter *) object; - if (stream_splitter->lock) { - g_mutex_free (stream_splitter->lock); - stream_splitter->lock = NULL; - } - g_list_foreach (stream_splitter->pending_events, (GFunc) gst_event_unref, NULL); g_list_free (stream_splitter->pending_events); @@ -98,6 +95,16 @@ gst_stream_splitter_dispose (GObject * object) G_OBJECT_CLASS (gst_stream_splitter_parent_class)->dispose (object); } +static void +gst_stream_splitter_finalize (GObject * object) +{ + GstStreamSplitter *stream_splitter = (GstStreamSplitter *) object; + + g_mutex_clear (&stream_splitter->lock); + + G_OBJECT_CLASS (gst_stream_splitter_parent_class)->finalize (object); +} + static GstFlowReturn gst_stream_splitter_chain (GstPad * pad, GstObject * parent, GstBuffer * buf) { @@ -416,7 +423,7 @@ gst_stream_splitter_init (GstStreamSplitter * stream_splitter) gst_stream_splitter_sink_query); gst_element_add_pad (GST_ELEMENT (stream_splitter), stream_splitter->sinkpad); - stream_splitter->lock = g_mutex_new (); + g_mutex_init (&stream_splitter->lock); } static GstPad * diff --git a/gst/encoding/gststreamsplitter.h b/gst/encoding/gststreamsplitter.h index b503c00..8fa1dea 100644 --- a/gst/encoding/gststreamsplitter.h +++ b/gst/encoding/gststreamsplitter.h @@ -41,7 +41,7 @@ struct _GstStreamSplitter { * * the current pad * * the list of srcpads */ - GMutex *lock; + GMutex lock; /* Currently activated srcpad */ GstPad *current; GList *srcpads;