[0.11] gst-plugins-good: alpha: use new glib API for static mutex if available

Sebastian Dröge slomo at kemper.freedesktop.org
Tue Jan 10 05:33:01 PST 2012


Module: gst-plugins-good
Branch: 0.11
Commit: f60eb9ae2c2ebb402fafbfa314970890e9f3342b
URL:    http://cgit.freedesktop.org/gstreamer/gst-plugins-good/commit/?id=f60eb9ae2c2ebb402fafbfa314970890e9f3342b

Author: Tim-Philipp Müller <tim.muller at collabora.co.uk>
Date:   Mon Dec 12 02:31:36 2011 +0000

alpha: use new glib API for static mutex if available

---

 gst/alpha/gstalpha.c |   22 ++++++++++++++++++++++
 gst/alpha/gstalpha.h |    4 ++++
 2 files changed, 26 insertions(+), 0 deletions(-)

diff --git a/gst/alpha/gstalpha.c b/gst/alpha/gstalpha.c
index 65aae69..f4d0cce 100644
--- a/gst/alpha/gstalpha.c
+++ b/gst/alpha/gstalpha.c
@@ -161,6 +161,8 @@ static GstStaticCaps gst_alpha_alpha_caps =
     ";" GST_VIDEO_CAPS_ARGB ";" GST_VIDEO_CAPS_BGRA ";" GST_VIDEO_CAPS_ABGR ";"
     GST_VIDEO_CAPS_RGBA);
 
+/* FIXME: why do we need our own lock for this? */
+#if !GLIB_CHECK_VERSION (2, 31, 0)
 #define GST_ALPHA_LOCK(alpha) G_STMT_START { \
   GST_LOG_OBJECT (alpha, "Locking alpha from thread %p", g_thread_self ()); \
   g_static_mutex_lock (&alpha->lock); \
@@ -171,6 +173,18 @@ static GstStaticCaps gst_alpha_alpha_caps =
   GST_LOG_OBJECT (alpha, "Unlocking alpha from thread %p", g_thread_self ()); \
   g_static_mutex_unlock (&alpha->lock); \
 } G_STMT_END
+#else
+#define GST_ALPHA_LOCK(alpha) G_STMT_START { \
+  GST_LOG_OBJECT (alpha, "Locking alpha from thread %p", g_thread_self ()); \
+  g_mutex_lock (&alpha->lock); \
+  GST_LOG_OBJECT (alpha, "Locked alpha from thread %p", g_thread_self ()); \
+} G_STMT_END
+
+#define GST_ALPHA_UNLOCK(alpha) G_STMT_START { \
+  GST_LOG_OBJECT (alpha, "Unlocking alpha from thread %p", g_thread_self ()); \
+  g_mutex_unlock (&alpha->lock); \
+} G_STMT_END
+#endif
 
 static gboolean gst_alpha_start (GstBaseTransform * trans);
 static gboolean gst_alpha_get_unit_size (GstBaseTransform * btrans,
@@ -312,7 +326,11 @@ gst_alpha_init (GstAlpha * alpha, GstAlphaClass * klass)
   alpha->black_sensitivity = DEFAULT_BLACK_SENSITIVITY;
   alpha->white_sensitivity = DEFAULT_WHITE_SENSITIVITY;
 
+#if !GLIB_CHECK_VERSION (2, 31, 0)
   g_static_mutex_init (&alpha->lock);
+#else
+  g_mutex_init (&alpha->lock);
+#endif
 }
 
 static void
@@ -320,7 +338,11 @@ gst_alpha_finalize (GObject * object)
 {
   GstAlpha *alpha = GST_ALPHA (object);
 
+#if !GLIB_CHECK_VERSION (2, 31, 0)
   g_static_mutex_free (&alpha->lock);
+#else
+  g_mutex_clear (&alpha->lock);
+#endif
 
   G_OBJECT_CLASS (parent_class)->finalize (object);
 }
diff --git a/gst/alpha/gstalpha.h b/gst/alpha/gstalpha.h
index 4402557..5de966e 100644
--- a/gst/alpha/gstalpha.h
+++ b/gst/alpha/gstalpha.h
@@ -70,7 +70,11 @@ struct _GstAlpha
   /* <private> */
 
   /* caps */
+#if !GLIB_CHECK_VERSION (2, 31, 0)
   GStaticMutex lock;
+#else
+  GMutex lock;
+#endif
 
   GstVideoFormat in_format, out_format;
   gint width, height;



More information about the gstreamer-commits mailing list