[aravis/aravis-0-2] all: avoid deprecation warnings on g_static_mutex API.



commit 68a7636a71db0cf4e0876e66cd3111377264a0a6
Author: Emmanuel Pacaud <emmanuel gnome org>
Date:   Sun Apr 28 16:33:14 2013 +0200

    all: avoid deprecation warnings on g_static_mutex API.

 src/arvfakeinterface.c |   12 ++++++------
 src/arvgvinterface.c   |   11 ++++++-----
 src/arvmisc.h          |   14 ++++++++++++--
 3 files changed, 24 insertions(+), 13 deletions(-)
---
diff --git a/src/arvfakeinterface.c b/src/arvfakeinterface.c
index 52819a0..5b24d34 100644
--- a/src/arvfakeinterface.c
+++ b/src/arvfakeinterface.c
@@ -28,6 +28,7 @@
 #include <arvfakeinterface.h>
 #include <arvfakedevice.h>
 #include <arvdebug.h>
+#include <arvmisc.h>
 
 #define ARV_FAKE_DEVICE_ID "Fake_1"
 #define ARV_FAKE_PHYSICAL_ID "Fake_1"
@@ -67,7 +68,7 @@ arv_fake_interface_open_device (ArvInterface *interface, const char *device_id)
 }
 
 static ArvInterface *fake_interface = NULL;
-static GStaticMutex fake_interface_mutex = G_STATIC_MUTEX_INIT;
+ARV_DEFINE_STATIC_MUTEX (fake_interface_mutex);
 
 /**
  * arv_fake_interface_get_instance:
@@ -80,13 +81,12 @@ static GStaticMutex fake_interface_mutex = G_STATIC_MUTEX_INIT;
 ArvInterface *
 arv_fake_interface_get_instance (void)
 {
-
-       g_static_mutex_lock (&fake_interface_mutex);
+       arv_g_mutex_lock (&fake_interface_mutex);
 
        if (fake_interface == NULL)
                fake_interface = g_object_new (ARV_TYPE_FAKE_INTERFACE, NULL);
 
-       g_static_mutex_unlock (&fake_interface_mutex);
+       arv_g_mutex_unlock (&fake_interface_mutex);
 
        return ARV_INTERFACE (fake_interface);
 }
@@ -94,14 +94,14 @@ arv_fake_interface_get_instance (void)
 void
 arv_fake_interface_destroy_instance (void)
 {
-       g_static_mutex_lock (&fake_interface_mutex);
+       arv_g_mutex_lock (&fake_interface_mutex);
 
        if (fake_interface != NULL) {
                g_object_unref (fake_interface);
                fake_interface = NULL;
        }
 
-       g_static_mutex_unlock (&fake_interface_mutex);
+       arv_g_mutex_unlock (&fake_interface_mutex);
 }
 
 static void
diff --git a/src/arvgvinterface.c b/src/arvgvinterface.c
index 0061831..db3f91c 100644
--- a/src/arvgvinterface.c
+++ b/src/arvgvinterface.c
@@ -29,6 +29,7 @@
 #include <arvgvdevice.h>
 #include <arvgvcp.h>
 #include <arvdebug.h>
+#include <arvmisc.h>
 #include <glib/gprintf.h>
 #include <gio/gio.h>
 #include <sys/types.h>
@@ -392,7 +393,7 @@ arv_gv_interface_open_device (ArvInterface *interface, const char *device_id)
 }
 
 static ArvInterface *gv_interface = NULL;
-static GStaticMutex gv_interface_mutex = G_STATIC_MUTEX_INIT;
+ARV_DEFINE_STATIC_MUTEX (gv_interface_mutex);
 
 /**
  * arv_gv_interface_get_instance:
@@ -405,12 +406,12 @@ static GStaticMutex gv_interface_mutex = G_STATIC_MUTEX_INIT;
 ArvInterface *
 arv_gv_interface_get_instance (void)
 {
-       g_static_mutex_lock (&gv_interface_mutex);
+       arv_g_mutex_lock (&gv_interface_mutex);
 
        if (gv_interface == NULL)
                gv_interface = g_object_new (ARV_TYPE_GV_INTERFACE, NULL);
 
-       g_static_mutex_unlock (&gv_interface_mutex);
+       arv_g_mutex_unlock (&gv_interface_mutex);
 
        return ARV_INTERFACE (gv_interface);
 }
@@ -418,14 +419,14 @@ arv_gv_interface_get_instance (void)
 void
 arv_gv_interface_destroy_instance (void)
 {
-       g_static_mutex_lock (&gv_interface_mutex);
+       arv_g_mutex_lock (&gv_interface_mutex);
 
        if (gv_interface != NULL) {
                g_object_unref (gv_interface);
                gv_interface = NULL;
        }
 
-       g_static_mutex_unlock (&gv_interface_mutex);
+       arv_g_mutex_unlock (&gv_interface_mutex);
 }
 
 static void
diff --git a/src/arvmisc.h b/src/arvmisc.h
index ae7b4bc..7d477e1 100644
--- a/src/arvmisc.h
+++ b/src/arvmisc.h
@@ -74,10 +74,20 @@ ArvPixelFormat      arv_pixel_format_from_gst_caps          (const char *name, int bpp, 
int
    Compatibility with old glib
  */
 
-#if !GLIB_CHECK_VERSION(2,36,0)
+#if GLIB_CHECK_VERSION(2,36,0)
+#define arv_g_type_init()
+#else
 #define arv_g_type_init() g_type_init()
+#endif
+
+#if GLIB_CHECK_VERSION(2,32,0)
+#define ARV_DEFINE_STATIC_MUTEX(mutex) static GMutex mutex
+#define arv_g_mutex_lock(mutex) g_mutex_lock(mutex)
+#define arv_g_mutex_unlock(mutex) g_mutex_unlock(mutex)
 #else
-#define arv_g_type_init()
+#define ARV_DEFINE_STATIC_MUTEX(mutex) static GStaticMutex mutex = G_STATIC_MUTEX_INIT
+#define arv_g_mutex_lock(mutex) g_static_mutex_lock(mutex)
+#define arv_g_mutex_unlock(mutex) g_static_mutex_unlock(mutex)
 #endif
 
 G_END_DECLS


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]