diff options
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/mock/uca-mock-camera.c | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/plugins/mock/uca-mock-camera.c b/plugins/mock/uca-mock-camera.c index d886378..49e1dcd 100644 --- a/plugins/mock/uca-mock-camera.c +++ b/plugins/mock/uca-mock-camera.c @@ -19,6 +19,7 @@ #include <gio/gio.h> #include <string.h> #include <math.h> +#include <signal.h> #include "uca-mock-camera.h" #define UCA_MOCK_CAMERA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), UCA_TYPE_MOCK_CAMERA, UcaMockCameraPrivate)) @@ -52,6 +53,9 @@ static const gint mock_overrideables[] = { static GParamSpec *mock_properties[N_PROPERTIES] = { NULL, }; +static GMutex signal_mutex; +static GCond signal_cond; + struct _UcaMockCameraPrivate { guint width; guint height; @@ -258,6 +262,14 @@ mock_grab_func(gpointer data) } static void +handle_sigusr1 (int signum) +{ + g_mutex_lock (&signal_mutex); + g_cond_signal (&signal_cond); + g_mutex_unlock (&signal_mutex); +} + +static void uca_mock_camera_start_recording(UcaCamera *camera, GError **error) { gboolean transfer_async = FALSE; @@ -265,12 +277,12 @@ uca_mock_camera_start_recording(UcaCamera *camera, GError **error) g_return_if_fail(UCA_IS_MOCK_CAMERA(camera)); priv = UCA_MOCK_CAMERA_GET_PRIVATE(camera); + signal (SIGUSR1, handle_sigusr1); + /* TODO: check that roi_x + roi_width < priv->width */ priv->dummy_data = (guint8 *) g_malloc0(priv->roi_width * priv->roi_height * priv->bytes); - g_object_get(G_OBJECT(camera), - "transfer-asynchronously", &transfer_async, - NULL); + g_object_get(G_OBJECT(camera), "transfer-asynchronously", &transfer_async, NULL); /* * In case asynchronous transfer is requested, we start a new thread that @@ -343,6 +355,13 @@ uca_mock_camera_grab (UcaCamera *camera, gpointer data, GError **error) if (trigger_source == UCA_CAMERA_TRIGGER_SOURCE_SOFTWARE) g_free (g_async_queue_pop (priv->trigger_queue)); + if (trigger_source == UCA_CAMERA_TRIGGER_SOURCE_EXTERNAL) { + /* wait for signal to arrive */ + g_mutex_lock (&signal_mutex); + g_cond_wait (&signal_cond, &signal_mutex); + g_mutex_unlock (&signal_mutex); + } + g_usleep (G_USEC_PER_SEC * exposure_time); if (priv->fill_data) { |