From 952f347146963b8d02aa03fb61e1fda6e28018f7 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Mon, 10 Sep 2012 01:10:24 +0100 Subject: [PATCH] playback: port to new GLib thread API --- gst/playback/gstplaysinkconvertbin.c | 4 ++-- gst/playback/gstplaysinkconvertbin.h | 6 +++--- gst/playback/gstsubtitleoverlay.c | 33 +++++++++++++-------------------- gst/playback/gstsubtitleoverlay.h | 8 ++++---- 4 files changed, 22 insertions(+), 29 deletions(-) diff --git a/gst/playback/gstplaysinkconvertbin.c b/gst/playback/gstplaysinkconvertbin.c index 0b5c368..b6e3374 100644 --- a/gst/playback/gstplaysinkconvertbin.c +++ b/gst/playback/gstplaysinkconvertbin.c @@ -500,7 +500,7 @@ gst_play_sink_convert_bin_finalize (GObject * object) GstPlaySinkConvertBin *self = GST_PLAY_SINK_CONVERT_BIN_CAST (object); gst_object_unref (self->sink_proxypad); - g_mutex_free (self->lock); + g_mutex_clear (&self->lock); G_OBJECT_CLASS (parent_class)->finalize (object); } @@ -616,7 +616,7 @@ gst_play_sink_convert_bin_init (GstPlaySinkConvertBin * self) { GstPadTemplate *templ; - self->lock = g_mutex_new (); + g_mutex_init (&self->lock); gst_segment_init (&self->segment, GST_FORMAT_UNDEFINED); templ = gst_static_pad_template_get (&sinktemplate); diff --git a/gst/playback/gstplaysinkconvertbin.h b/gst/playback/gstplaysinkconvertbin.h index fd787d9..3a9e8d3 100644 --- a/gst/playback/gstplaysinkconvertbin.h +++ b/gst/playback/gstplaysinkconvertbin.h @@ -41,7 +41,7 @@ G_BEGIN_DECLS GST_LOG_OBJECT (obj, \ "locking from thread %p", \ g_thread_self ()); \ - g_mutex_lock (GST_PLAY_SINK_CONVERT_BIN_CAST(obj)->lock); \ + g_mutex_lock (&GST_PLAY_SINK_CONVERT_BIN_CAST(obj)->lock); \ GST_LOG_OBJECT (obj, \ "locked from thread %p", \ g_thread_self ()); \ @@ -51,7 +51,7 @@ G_BEGIN_DECLS GST_LOG_OBJECT (obj, \ "unlocking from thread %p", \ g_thread_self ()); \ - g_mutex_unlock (GST_PLAY_SINK_CONVERT_BIN_CAST(obj)->lock); \ + g_mutex_unlock (&GST_PLAY_SINK_CONVERT_BIN_CAST(obj)->lock); \ } G_STMT_END typedef struct _GstPlaySinkConvertBin GstPlaySinkConvertBin; @@ -62,7 +62,7 @@ struct _GstPlaySinkConvertBin GstBin parent; /* < private > */ - GMutex *lock; + GMutex lock; GstPad *sinkpad, *sink_proxypad; guint sink_proxypad_block_id; diff --git a/gst/playback/gstsubtitleoverlay.c b/gst/playback/gstsubtitleoverlay.c index caf431d..e42f381 100644 --- a/gst/playback/gstsubtitleoverlay.c +++ b/gst/playback/gstsubtitleoverlay.c @@ -162,15 +162,8 @@ gst_subtitle_overlay_finalize (GObject * object) { GstSubtitleOverlay *self = GST_SUBTITLE_OVERLAY (object); - if (self->lock) { - g_mutex_free (self->lock); - self->lock = NULL; - } - - if (self->factories_lock) { - g_mutex_free (self->factories_lock); - self->factories_lock = NULL; - } + g_mutex_clear (&self->lock); + g_mutex_clear (&self->factories_lock); if (self->factories) gst_plugin_feature_list_free (self->factories); @@ -1181,7 +1174,7 @@ _pad_blocked_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data) self->subtitle_flush = FALSE; /* Find our factories */ - g_mutex_lock (self->factories_lock); + g_mutex_lock (&self->factories_lock); gst_subtitle_overlay_update_factory_list (self); if (subcaps) { factories = @@ -1197,7 +1190,7 @@ _pad_blocked_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data) self->subtitle_error = TRUE; } } - g_mutex_unlock (self->factories_lock); + g_mutex_unlock (&self->factories_lock); if (!subcaps) { _setup_passthrough (self); @@ -1254,14 +1247,14 @@ _pad_blocked_cb (GstPad * pad, GstPadProbeInfo * info, gpointer user_data) g_assert (parser_caps != NULL); - g_mutex_lock (self->factories_lock); + g_mutex_lock (&self->factories_lock); gst_subtitle_overlay_update_factory_list (self); GST_DEBUG_OBJECT (self, "Searching overlay factories for caps %" GST_PTR_FORMAT, parser_caps); overlay_factories = gst_subtitle_overlay_get_factories_for_caps (self->factories, parser_caps); - g_mutex_unlock (self->factories_lock); + g_mutex_unlock (&self->factories_lock); if (!overlay_factories) { GST_WARNING_OBJECT (self, @@ -1427,12 +1420,12 @@ gst_subtitle_overlay_change_state (GstElement * element, switch (transition) { case GST_STATE_CHANGE_NULL_TO_READY: GST_DEBUG_OBJECT (self, "State change NULL->READY"); - g_mutex_lock (self->factories_lock); + g_mutex_lock (&self->factories_lock); if (G_UNLIKELY (!gst_subtitle_overlay_update_factory_list (self))) { - g_mutex_unlock (self->factories_lock); + g_mutex_unlock (&self->factories_lock); return GST_STATE_CHANGE_FAILURE; } - g_mutex_unlock (self->factories_lock); + g_mutex_unlock (&self->factories_lock); GST_SUBTITLE_OVERLAY_LOCK (self); /* Set the internal pads to blocking */ @@ -1940,7 +1933,7 @@ gst_subtitle_overlay_subtitle_sink_getcaps (GstPad * pad, GstCaps * filter) GstSubtitleOverlay *self = GST_SUBTITLE_OVERLAY (gst_pad_get_parent (pad)); GstCaps *ret; - g_mutex_lock (self->factories_lock); + g_mutex_lock (&self->factories_lock); if (G_UNLIKELY (!gst_subtitle_overlay_update_factory_list (self))) ret = gst_caps_new_empty (); else if (filter) @@ -1949,7 +1942,7 @@ gst_subtitle_overlay_subtitle_sink_getcaps (GstPad * pad, GstCaps * filter) GST_CAPS_INTERSECT_FIRST); else ret = gst_caps_ref (self->factory_caps); - g_mutex_unlock (self->factories_lock); + g_mutex_unlock (&self->factories_lock); GST_DEBUG_OBJECT (pad, "Returning subtitle caps %" GST_PTR_FORMAT, ret); @@ -2229,8 +2222,8 @@ gst_subtitle_overlay_init (GstSubtitleOverlay * self) GstPadTemplate *templ; GstPad *proxypad = NULL; - self->lock = g_mutex_new (); - self->factories_lock = g_mutex_new (); + g_mutex_init (&self->lock); + g_mutex_init (&self->factories_lock); templ = gst_static_pad_template_get (&srctemplate); self->srcpad = gst_ghost_pad_new_no_target_from_template ("src", templ); diff --git a/gst/playback/gstsubtitleoverlay.h b/gst/playback/gstsubtitleoverlay.h index 0fe6b1b..a21ed28 100644 --- a/gst/playback/gstsubtitleoverlay.h +++ b/gst/playback/gstsubtitleoverlay.h @@ -40,7 +40,7 @@ G_BEGIN_DECLS GST_LOG_OBJECT (obj, \ "locking from thread %p", \ g_thread_self ()); \ - g_mutex_lock (GST_SUBTITLE_OVERLAY_CAST(obj)->lock); \ + g_mutex_lock (&GST_SUBTITLE_OVERLAY_CAST(obj)->lock); \ GST_LOG_OBJECT (obj, \ "locked from thread %p", \ g_thread_self ()); \ @@ -50,7 +50,7 @@ G_BEGIN_DECLS GST_LOG_OBJECT (obj, \ "unlocking from thread %p", \ g_thread_self ()); \ - g_mutex_unlock (GST_SUBTITLE_OVERLAY_CAST(obj)->lock); \ + g_mutex_unlock (&GST_SUBTITLE_OVERLAY_CAST(obj)->lock); \ } G_STMT_END typedef struct _GstSubtitleOverlay GstSubtitleOverlay; @@ -85,12 +85,12 @@ struct _GstSubtitleOverlay gboolean subtitle_flush; gboolean subtitle_error; - GMutex *factories_lock; + GMutex factories_lock; GList *factories; guint32 factories_cookie; GstCaps *factory_caps; - GMutex *lock; + GMutex lock; GstCaps *subcaps; GstElement *passthrough_identity; -- 2.7.4