playback: port to new GLib thread API
authorTim-Philipp Müller <tim@centricular.net>
Mon, 10 Sep 2012 00:10:24 +0000 (01:10 +0100)
committerTim-Philipp Müller <tim@centricular.net>
Mon, 10 Sep 2012 00:10:24 +0000 (01:10 +0100)
gst/playback/gstplaysinkconvertbin.c
gst/playback/gstplaysinkconvertbin.h
gst/playback/gstsubtitleoverlay.c
gst/playback/gstsubtitleoverlay.h

index 0b5c3686ccf9dd6f955d0135b662eb94a7b93dd1..b6e3374c1e9f305c9d3c21f4be45b42c656fd97c 100644 (file)
@@ -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);
index fd787d923f511c2189e3900a10c33c3276fdca25..3a9e8d30c63dc0a0b90e7224cf890bf03449a0c4 100644 (file)
@@ -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;
index caf431dbdc27d5c00376bce189ce47d5726269cf..e42f3818742e3b077287f6973cf10c9f48735dde 100644 (file)
@@ -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);
index 0fe6b1bd0004b5969751276e8a96eee51a44af59..a21ed280d0f93ad6cbde3b82c4e6b8aa4e4f9d26 100644 (file)
@@ -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;