diff options
Diffstat (limited to 'src/uca-camera.c')
-rw-r--r-- | src/uca-camera.c | 38 |
1 files changed, 21 insertions, 17 deletions
diff --git a/src/uca-camera.c b/src/uca-camera.c index 8905a95..5073a57 100644 --- a/src/uca-camera.c +++ b/src/uca-camera.c @@ -116,6 +116,7 @@ struct _UcaCameraPrivate { gboolean is_recording; gboolean is_readout; gboolean transfer_async; + UcaCameraTrigger trigger; }; static void @@ -148,6 +149,10 @@ uca_camera_set_property (GObject *object, guint property_id, const GValue *value } break; + case PROP_TRIGGER_MODE: + priv->trigger = g_value_get_enum (value); + break; + default: G_OBJECT_WARN_INVALID_PROPERTY_ID(object, property_id, pspec); } @@ -172,7 +177,7 @@ uca_camera_get_property(GObject *object, guint property_id, GValue *value, GPara break; case PROP_TRIGGER_MODE: - g_value_set_enum (value, UCA_CAMERA_TRIGGER_AUTO); + g_value_set_enum (value, priv->trigger); break; case PROP_FRAMES_PER_SECOND: @@ -403,6 +408,7 @@ uca_camera_init (UcaCamera *camera) camera->priv->is_recording = FALSE; camera->priv->is_readout = FALSE; camera->priv->transfer_async = FALSE; + camera->priv->trigger = UCA_CAMERA_TRIGGER_AUTO; uca_camera_set_property_unit (camera_properties[PROP_SENSOR_WIDTH], UCA_UNIT_PIXEL); uca_camera_set_property_unit (camera_properties[PROP_SENSOR_HEIGHT], UCA_UNIT_PIXEL); @@ -669,34 +675,31 @@ uca_camera_trigger (UcaCamera *camera, GError **error) /** * uca_camera_grab: * @camera: A #UcaCamera object - * @data: Pointer to pointer to the data. Must not be %NULL. + * @data: (type gulong): Pointer to suitably sized data buffer. Must not be + * %NULL. * @error: Location to store a #UcaCameraError error or %NULL * - * Grab a frame a single frame and store the result in @data. If the pointer - * pointing to the data is %NULL, memory will be allocated otherwise it will be - * used to store the frame. If memory is allocated by uca_camera_grab() it must - * be freed by the caller. + * Grab a frame a single frame and store the result in @data. * * You must have called uca_camera_start_recording() before, otherwise you will * get a #UCA_CAMERA_ERROR_NOT_RECORDING error. - * - * If *data is %NULL after returning from uca_camera_grab() and error is also - * %NULL, the data stream has ended. For example, with cameras that support - * in-camera memory, all frames have been transfered. */ -void -uca_camera_grab (UcaCamera *camera, gpointer *data, GError **error) +gboolean +uca_camera_grab (UcaCamera *camera, gpointer data, GError **error) { UcaCameraClass *klass; + gboolean result; + + /* FIXME: this prevents accessing two independent cameras simultanously. */ static GStaticMutex mutex = G_STATIC_MUTEX_INIT; - g_return_if_fail (UCA_IS_CAMERA(camera)); + g_return_val_if_fail (UCA_IS_CAMERA(camera), FALSE); klass = UCA_CAMERA_GET_CLASS (camera); - g_return_if_fail (klass != NULL); - g_return_if_fail (klass->grab != NULL); - g_return_if_fail (data != NULL); + g_return_val_if_fail (klass != NULL, FALSE); + g_return_val_if_fail (klass->grab != NULL, FALSE); + g_return_val_if_fail (data != NULL, FALSE); g_static_mutex_lock (&mutex); @@ -704,11 +707,12 @@ uca_camera_grab (UcaCamera *camera, gpointer *data, GError **error) g_set_error (error, UCA_CAMERA_ERROR, UCA_CAMERA_ERROR_NOT_RECORDING, "Camera is neither recording nor in readout mode"); else { g_static_mutex_lock (&access_lock); - (*klass->grab) (camera, data, error); + result = (*klass->grab) (camera, data, error); g_static_mutex_unlock (&access_lock); } g_static_mutex_unlock (&mutex); + return result; } /** |