diff options
author | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2012-10-22 16:35:48 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-10-22 16:42:50 +0200 |
commit | a835d4e4b054b665a834e81e6e3437accb1de59f (patch) | |
tree | 2d7790fe714b7f3e24e193b843c898d12106750d /src | |
parent | 6f12303cf4c4130d544c30f8ad5e2445a1fa3e61 (diff) | |
download | uca-a835d4e4b054b665a834e81e6e3437accb1de59f.tar.gz uca-a835d4e4b054b665a834e81e6e3437accb1de59f.tar.bz2 uca-a835d4e4b054b665a834e81e6e3437accb1de59f.tar.xz uca-a835d4e4b054b665a834e81e6e3437accb1de59f.zip |
Lock access to camera implementations
Thus, two threads will never invoke the camera implementations of grab() and stop().
Diffstat (limited to 'src')
-rw-r--r-- | src/uca-camera.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/src/uca-camera.c b/src/uca-camera.c index 53b2d7a..8905a95 100644 --- a/src/uca-camera.c +++ b/src/uca-camera.c @@ -110,6 +110,7 @@ const gchar *uca_camera_props[N_BASE_PROPERTIES] = { }; static GParamSpec *camera_properties[N_BASE_PROPERTIES] = { NULL, }; +static GStaticMutex access_lock = G_STATIC_MUTEX_INIT; struct _UcaCameraPrivate { gboolean is_recording; @@ -457,7 +458,9 @@ uca_camera_start_recording (UcaCamera *camera, GError **error) goto start_recording_unlock; } + g_static_mutex_lock (&access_lock); (*klass->start_recording)(camera, &tmp_error); + g_static_mutex_unlock (&access_lock); if (tmp_error == NULL) { camera->priv->is_readout = FALSE; @@ -501,7 +504,9 @@ uca_camera_stop_recording (UcaCamera *camera, GError **error) else { GError *tmp_error = NULL; + g_static_mutex_lock (&access_lock); (*klass->stop_recording)(camera, &tmp_error); + g_static_mutex_unlock (&access_lock); if (tmp_error == NULL) { camera->priv->is_readout = FALSE; @@ -548,7 +553,9 @@ uca_camera_start_readout (UcaCamera *camera, GError **error) else { GError *tmp_error = NULL; + g_static_mutex_lock (&access_lock); (*klass->start_readout) (camera, &tmp_error); + g_static_mutex_unlock (&access_lock); if (tmp_error == NULL) { camera->priv->is_readout = TRUE; @@ -593,7 +600,9 @@ uca_camera_stop_readout (UcaCamera *camera, GError **error) else { GError *tmp_error = NULL; + g_static_mutex_lock (&access_lock); (*klass->stop_readout) (camera, &tmp_error); + g_static_mutex_unlock (&access_lock); if (tmp_error == NULL) { camera->priv->is_readout = FALSE; @@ -648,8 +657,11 @@ uca_camera_trigger (UcaCamera *camera, GError **error) if (!camera->priv->is_recording) g_set_error (error, UCA_CAMERA_ERROR, UCA_CAMERA_ERROR_NOT_RECORDING, "Camera is not recording"); - else + else { + g_static_mutex_lock (&access_lock); (*klass->trigger) (camera, error); + g_static_mutex_unlock (&access_lock); + } g_static_mutex_unlock (&mutex); } @@ -690,8 +702,11 @@ uca_camera_grab (UcaCamera *camera, gpointer *data, GError **error) if (!camera->priv->is_recording && !camera->priv->is_readout) g_set_error (error, UCA_CAMERA_ERROR, UCA_CAMERA_ERROR_NOT_RECORDING, "Camera is neither recording nor in readout mode"); - else + else { + g_static_mutex_lock (&access_lock); (*klass->grab) (camera, data, error); + g_static_mutex_unlock (&access_lock); + } g_static_mutex_unlock (&mutex); } |