[aravis] aravis: add arv_shutdown.
- From: Emmanuel Pacaud <emmanuel src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [aravis] aravis: add arv_shutdown.
- Date: Thu, 17 Feb 2011 19:44:34 +0000 (UTC)
commit 7981254529b7a88fff78ed684dd027d58df8f097
Author: Emmanuel Pacaud <emmanuel gnome org>
Date: Thu Feb 17 20:42:22 2011 +0100
aravis: add arv_shutdown.
It cleans interface instances, to ensure there's no aravis object
alive when exiting. It's mainly for debugging purpose. Useful when
used together with :
http://blogs.gnome.org/danni/2011/02/17/ld_preload-gobject-lifetime-debugging-tool/
docs/reference/aravis/aravis-sections.txt | 3 +++
src/arvcamera.c | 2 +-
src/arvfakeinterface.c | 24 ++++++++++++++++++------
src/arvfakeinterface.h | 1 +
src/arvgvinterface.c | 25 ++++++++++++++++++-------
src/arvgvinterface.h | 1 +
src/arvshowdevices.c | 3 +++
src/arvsystem.c | 15 ++++++++++++---
src/arvsystem.h | 2 ++
tests/buffer.c | 7 ++++++-
tests/evaluator.c | 7 ++++++-
tests/fake.c | 7 ++++++-
viewer/arvviewer.c | 3 +++
13 files changed, 80 insertions(+), 20 deletions(-)
---
diff --git a/docs/reference/aravis/aravis-sections.txt b/docs/reference/aravis/aravis-sections.txt
index 40047ba..7b79afb 100644
--- a/docs/reference/aravis/aravis-sections.txt
+++ b/docs/reference/aravis/aravis-sections.txt
@@ -88,6 +88,7 @@ arv_get_n_devices
arv_get_n_interfaces
arv_update_device_list
arv_open_device
+arv_shutdown
arv_interface_update_device_list
arv_interface_get_device_id
arv_interface_get_n_devices
@@ -110,6 +111,7 @@ ArvInterfacePrivate
<TITLE>ArvFakeInterface</TITLE>
ArvFakeInterface
arv_fake_interface_get_instance
+arv_fake_interface_destroy_instance
<SUBSECTION Standard>
ARV_FAKE_INTERFACE
ARV_IS_FAKE_INTERFACE
@@ -388,6 +390,7 @@ arv_gc_set_double_to_value
<TITLE>ArvGvInterface</TITLE>
ArvGvInterface
arv_gv_interface_get_instance
+arv_gv_interface_destroy_instance
<SUBSECTION Standard>
ARV_GV_INTERFACE
ARV_IS_GV_INTERFACE
diff --git a/src/arvcamera.c b/src/arvcamera.c
index cbe7236..4a0405c 100644
--- a/src/arvcamera.c
+++ b/src/arvcamera.c
@@ -525,7 +525,7 @@ arv_camera_set_trigger (ArvCamera *camera, const char *source)
/**
* arv_camera_software_trigger:
- * @amera: a #ArvCamera
+ * @camera: a #ArvCamera
*
* Sends a software trigger command to @camera. The camera must be previously
* configured to use a software trigger, using @arv_camera_set_trigger.
diff --git a/src/arvfakeinterface.c b/src/arvfakeinterface.c
index cc2e31e..81cc148 100644
--- a/src/arvfakeinterface.c
+++ b/src/arvfakeinterface.c
@@ -56,24 +56,36 @@ arv_fake_interface_open_device (ArvInterface *interface, const char *device_id)
return NULL;
}
+static ArvInterface *fake_interface = NULL;
+static GStaticMutex fake_interface_mutex = G_STATIC_MUTEX_INIT;
+
ArvInterface *
arv_fake_interface_get_instance (void)
{
- static ArvInterface *fake_interface = NULL;
- static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
- g_static_mutex_lock (&mutex);
+ g_static_mutex_lock (&fake_interface_mutex);
if (fake_interface == NULL)
fake_interface = g_object_new (ARV_TYPE_FAKE_INTERFACE, NULL);
- else
- g_object_ref (fake_interface);
- g_static_mutex_unlock (&mutex);
+ g_static_mutex_unlock (&fake_interface_mutex);
return ARV_INTERFACE (fake_interface);
}
+void
+arv_fake_interface_destroy_instance (void)
+{
+ g_static_mutex_lock (&fake_interface_mutex);
+
+ if (fake_interface != NULL) {
+ g_object_unref (fake_interface);
+ fake_interface = NULL;
+ }
+
+ g_static_mutex_unlock (&fake_interface_mutex);
+}
+
static void
arv_fake_interface_init (ArvFakeInterface *fake_interface)
{
diff --git a/src/arvfakeinterface.h b/src/arvfakeinterface.h
index 623d184..54c5c60 100644
--- a/src/arvfakeinterface.h
+++ b/src/arvfakeinterface.h
@@ -54,6 +54,7 @@ struct _ArvFakeInterfaceClass {
GType arv_fake_interface_get_type (void);
ArvInterface * arv_fake_interface_get_instance (void);
+void arv_fake_interface_destroy_instance (void);
G_END_DECLS
diff --git a/src/arvgvinterface.c b/src/arvgvinterface.c
index e53d740..127399b 100644
--- a/src/arvgvinterface.c
+++ b/src/arvgvinterface.c
@@ -329,24 +329,35 @@ arv_gv_interface_open_device (ArvInterface *interface, const char *device_id)
return device;
}
+static ArvInterface *gv_interface = NULL;
+static GStaticMutex gv_interface_mutex = G_STATIC_MUTEX_INIT;
+
ArvInterface *
arv_gv_interface_get_instance (void)
{
- static ArvInterface *gv_interface = NULL;
- static GStaticMutex mutex = G_STATIC_MUTEX_INIT;
-
- g_static_mutex_lock (&mutex);
+ g_static_mutex_lock (&gv_interface_mutex);
if (gv_interface == NULL)
gv_interface = g_object_new (ARV_TYPE_GV_INTERFACE, NULL);
- else
- g_object_ref (gv_interface);
- g_static_mutex_unlock (&mutex);
+ g_static_mutex_unlock (&gv_interface_mutex);
return ARV_INTERFACE (gv_interface);
}
+void
+arv_gv_interface_destroy_instance (void)
+{
+ g_static_mutex_lock (&gv_interface_mutex);
+
+ if (gv_interface != NULL) {
+ g_object_unref (gv_interface);
+ gv_interface = NULL;
+ }
+
+ g_static_mutex_unlock (&gv_interface_mutex);
+}
+
static void
arv_gv_interface_init (ArvGvInterface *gv_interface)
{
diff --git a/src/arvgvinterface.h b/src/arvgvinterface.h
index c9e1b16..5e4c6c6 100644
--- a/src/arvgvinterface.h
+++ b/src/arvgvinterface.h
@@ -55,6 +55,7 @@ struct _ArvGvInterfaceClass {
GType arv_gv_interface_get_type (void);
ArvInterface * arv_gv_interface_get_instance (void);
+void arv_gv_interface_destroy_instance (void);
G_END_DECLS
diff --git a/src/arvshowdevices.c b/src/arvshowdevices.c
index 3e8c9fb..7a80e93 100644
--- a/src/arvshowdevices.c
+++ b/src/arvshowdevices.c
@@ -74,5 +74,8 @@ main (int argc, char **argv)
}
}
+ /* For debug purpose only */
+ arv_shutdown ();
+
return EXIT_SUCCESS;
}
diff --git a/src/arvsystem.c b/src/arvsystem.c
index aa2c6c2..0e0cb02 100644
--- a/src/arvsystem.c
+++ b/src/arvsystem.c
@@ -27,12 +27,13 @@
typedef struct {
const char *interface_id;
- ArvInterface * (*get_interface_instance) (void);
+ ArvInterface * (*get_interface_instance) (void);
+ void (*destroy_interface_instance) (void);
} ArvInterfaceInfos;
ArvInterfaceInfos interfaces[] = {
- {"Fake", arv_fake_interface_get_instance},
- {"GigE-Vision", arv_gv_interface_get_instance}
+ {"Fake", arv_fake_interface_get_instance, arv_fake_interface_destroy_instance},
+ {"GigE-Vision", arv_gv_interface_get_instance, arv_gv_interface_destroy_instance}
};
unsigned int
@@ -119,3 +120,11 @@ arv_open_device (const char *device_id)
return NULL;
}
+void
+arv_shutdown (void)
+{
+ unsigned int i;
+
+ for (i = 0; i < G_N_ELEMENTS (interfaces); i++)
+ interfaces[i].destroy_interface_instance ();
+}
diff --git a/src/arvsystem.h b/src/arvsystem.h
index 9fe75a0..d6b4a65 100644
--- a/src/arvsystem.h
+++ b/src/arvsystem.h
@@ -36,6 +36,8 @@ const char * arv_get_device_id (unsigned int index);
ArvDevice * arv_open_device (const char *device_id);
+void arv_shutdown (void);
+
G_END_DECLS
#endif
diff --git a/tests/buffer.c b/tests/buffer.c
index 3a419fb..68799c9 100644
--- a/tests/buffer.c
+++ b/tests/buffer.c
@@ -70,6 +70,7 @@ full_buffer_test (void)
int
main (int argc, char *argv[])
{
+ int result;
int i;
g_test_init (&argc, &argv, NULL);
@@ -80,6 +81,10 @@ main (int argc, char *argv[])
g_test_add_func ("/buffer/preallocated-buffer", preallocated_buffer_test);
g_test_add_func ("/buffer/full-buffer", full_buffer_test);
- return g_test_run();
+ result = g_test_run();
+
+ arv_shutdown ();
+
+ return result;
}
diff --git a/tests/evaluator.c b/tests/evaluator.c
index 5c7855b..22b9784 100644
--- a/tests/evaluator.c
+++ b/tests/evaluator.c
@@ -131,6 +131,7 @@ set_int64_variable_test (void)
int
main (int argc, char *argv[])
{
+ int result;
int i;
g_test_init (&argc, &argv, NULL);
@@ -146,5 +147,9 @@ main (int argc, char *argv[])
g_test_add_func ("/evaluator/double-variable", set_double_variable_test);
g_test_add_func ("/evaluator/int64-variable", set_int64_variable_test);
- return g_test_run();
+ result = g_test_run();
+
+ arv_shutdown ();
+
+ return result;
}
diff --git a/tests/fake.c b/tests/fake.c
index 4d3ad3a..ffba743 100644
--- a/tests/fake.c
+++ b/tests/fake.c
@@ -104,6 +104,7 @@ fake_device_test (void)
int
main (int argc, char *argv[])
{
+ int result;
int i;
g_test_init (&argc, &argv, NULL);
@@ -116,6 +117,10 @@ main (int argc, char *argv[])
g_test_add_func ("/fake/trigger-registers", trigger_registers_test);
g_test_add_func ("/fake/fake-device", fake_device_test);
- return g_test_run();
+ result = g_test_run();
+
+ arv_shutdown ();
+
+ return result;
}
diff --git a/viewer/arvviewer.c b/viewer/arvviewer.c
index b1497ae..cdfd729 100644
--- a/viewer/arvviewer.c
+++ b/viewer/arvviewer.c
@@ -543,5 +543,8 @@ main (int argc,char *argv[])
gtk_main ();
+ /* For debug purpose only */
+ arv_shutdown ();
+
return EXIT_SUCCESS;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]