[aravis] fake_camera: avoid deprecation warnings on g_mutex API.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis] fake_camera: avoid deprecation warnings on g_mutex API.
- Date: Sun, 28 Apr 2013 14:46:22 +0000 (UTC)
commit 559752d2e91959b4679b6c1d7e41d99a6c36de6b
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Sun Apr 28 16:45:53 2013 +0200
fake_camera: avoid deprecation warnings on g_mutex API.
src/arvfakecamera.c | 38 +++++++++++++++++++++++++++++++++-----
1 files changed, 33 insertions(+), 5 deletions(-)
---
diff --git a/src/arvfakecamera.c b/src/arvfakecamera.c
index 07e421a..e6da1f6 100644
--- a/src/arvfakecamera.c
+++ b/src/arvfakecamera.c
@@ -20,8 +20,6 @@
* Author: Emmanuel Pacaud <emmanuel gnome org>
*/
-#define GLIB_DISABLE_DEPRECATION_WARNINGS
-
/**
* SECTION: arvfakecamera
* @short_description: Fake camera internals
@@ -39,6 +37,7 @@
#include <arvgvcp.h>
#include <arvbuffer.h>
#include <arvdebug.h>
+#include <arvmisc.h>
#include <string.h>
#include <math.h>
@@ -52,7 +51,11 @@ struct _ArvFakeCameraPrivate {
guint32 frame_id;
double trigger_frequency;
+#if GLIB_CHECK_VERSION(2,32,0)
+ GMutex fill_pattern_mutex;
+#else
GMutex *fill_pattern_mutex;
+#endif
ArvFakeCameraFillPattern fill_pattern_callback;
void *fill_pattern_data;
};
@@ -232,7 +235,11 @@ arv_fake_camera_set_fill_pattern (ArvFakeCamera *camera,
{
g_return_if_fail (ARV_IS_FAKE_CAMERA (camera));
+#if GLIB_CHECK_VERSION(2,32,0)
+ g_mutex_lock (&camera->priv->fill_pattern_mutex);
+#else
g_mutex_lock (camera->priv->fill_pattern_mutex);
+#endif
if (fill_pattern_callback != NULL) {
camera->priv->fill_pattern_callback = fill_pattern_callback;
camera->priv->fill_pattern_data = fill_pattern_data;
@@ -240,7 +247,11 @@ arv_fake_camera_set_fill_pattern (ArvFakeCamera *camera,
camera->priv->fill_pattern_callback = arv_fake_camera_diagonal_ramp;
camera->priv->fill_pattern_data = NULL;
}
+#if GLIB_CHECK_VERSION(2,32,0)
+ g_mutex_unlock (&camera->priv->fill_pattern_mutex);
+#else
g_mutex_unlock (camera->priv->fill_pattern_mutex);
+#endif
}
void
@@ -275,13 +286,21 @@ arv_fake_camera_fill_buffer (ArvFakeCamera *camera, ArvBuffer *buffer, guint32 *
buffer->frame_id = camera->priv->frame_id++;
buffer->pixel_format = _get_register (camera, ARV_FAKE_CAMERA_REGISTER_PIXEL_FORMAT);
+#if GLIB_CHECK_VERSION(2,32,0)
+ g_mutex_lock (&camera->priv->fill_pattern_mutex);
+#else
g_mutex_lock (camera->priv->fill_pattern_mutex);
+#endif
arv_fake_camera_read_register (camera, ARV_FAKE_CAMERA_REGISTER_EXPOSURE_TIME_US, &exposure_time_us);
arv_fake_camera_read_register (camera, ARV_FAKE_CAMERA_REGISTER_GAIN_RAW, &gain);
arv_fake_camera_read_register (camera, ARV_FAKE_CAMERA_REGISTER_PIXEL_FORMAT, &pixel_format);
camera->priv->fill_pattern_callback (buffer, camera->priv->fill_pattern_data,
exposure_time_us, gain, pixel_format);
+#if GLIB_CHECK_VERSION(2,32,0)
+ g_mutex_unlock (&camera->priv->fill_pattern_mutex);
+#else
g_mutex_unlock (camera->priv->fill_pattern_mutex);
+#endif
if (packet_size != NULL)
*packet_size = _get_register (camera, ARV_GVBS_STREAM_CHANNEL_0_PACKET_SIZE_OFFSET);
@@ -383,9 +402,9 @@ const char *
arv_get_fake_camera_genicam_xml (size_t *size)
{
static GMappedFile *genicam_file = NULL;
- static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
+ ARV_DEFINE_STATIC_MUTEX (mutex);
- g_static_mutex_lock (&mutex);
+ arv_g_mutex_lock (&mutex);
if (genicam_file == NULL ) {
char *filename;
@@ -406,7 +425,7 @@ arv_get_fake_camera_genicam_xml (size_t *size)
g_free (filename);
}
- g_static_mutex_unlock (&mutex);
+ arv_g_mutex_unlock (&mutex);
g_return_val_if_fail( genicam_file != NULL, NULL);
@@ -433,7 +452,11 @@ arv_fake_camera_new (const char *serial_number)
memory = g_malloc0 (ARV_FAKE_CAMERA_MEMORY_SIZE);
+#if GLIB_CHECK_VERSION(2,32,0)
+ g_mutex_init (&fake_camera->priv->fill_pattern_mutex);
+#else
fake_camera->priv->fill_pattern_mutex = g_mutex_new ();
+#endif
fake_camera->priv->fill_pattern_callback = arv_fake_camera_diagonal_ramp;
fake_camera->priv->fill_pattern_data = NULL;
@@ -507,7 +530,12 @@ arv_fake_camera_finalize (GObject *object)
ArvFakeCamera *fake_camera = ARV_FAKE_CAMERA (object);
g_free (fake_camera->priv->memory);
+
+#if GLIB_CHECK_VERSION(2,32,0)
+ g_mutex_clear (&fake_camera->priv->fill_pattern_mutex);
+#else
g_mutex_free (fake_camera->priv->fill_pattern_mutex);
+#endif
parent_class->finalize (object);
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]