diff options
author | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2013-03-20 10:03:52 +0100 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2013-03-20 10:03:52 +0100 |
commit | ff7f3216fe76e0a4598bdf737671a5e25a780ded (patch) | |
tree | 611970247e33c4af6b1a2a6345bb39b3cb05295e /src | |
parent | 71acacfd31e36fcb314d0d75306d26f9518e1d6a (diff) | |
download | uca-ff7f3216fe76e0a4598bdf737671a5e25a780ded.tar.gz uca-ff7f3216fe76e0a4598bdf737671a5e25a780ded.tar.bz2 uca-ff7f3216fe76e0a4598bdf737671a5e25a780ded.tar.xz uca-ff7f3216fe76e0a4598bdf737671a5e25a780ded.zip |
uca_camera_grab takes a gpointer and returns bool
Diffstat (limited to 'src')
-rw-r--r-- | src/uca-camera.c | 30 | ||||
-rw-r--r-- | src/uca-camera.h | 9 |
2 files changed, 19 insertions, 20 deletions
diff --git a/src/uca-camera.c b/src/uca-camera.c index 8905a95..ec4b418 100644 --- a/src/uca-camera.c +++ b/src/uca-camera.c @@ -669,34 +669,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 +701,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; } /** diff --git a/src/uca-camera.h b/src/uca-camera.h index 87996c6..f6fdace 100644 --- a/src/uca-camera.h +++ b/src/uca-camera.h @@ -129,7 +129,7 @@ struct _UcaCameraClass { void (*start_readout) (UcaCamera *camera, GError **error); void (*stop_readout) (UcaCamera *camera, GError **error); void (*trigger) (UcaCamera *camera, GError **error); - void (*grab) (UcaCamera *camera, gpointer *data, GError **error); + gboolean (*grab) (UcaCamera *camera, gpointer data, GError **error); void (*recording_started) (UcaCamera *camera); void (*recording_stopped) (UcaCamera *camera); @@ -147,9 +147,10 @@ void uca_camera_stop_readout (UcaCamera *camera, GError **error); void uca_camera_trigger (UcaCamera *camera, GError **error); -void uca_camera_grab (UcaCamera *camera, - gpointer *data, - GError **error); +gboolean uca_camera_grab (UcaCamera *camera, + gpointer data, + GError **error) + __attribute__((nonnull (2))); void uca_camera_set_grab_func (UcaCamera *camera, UcaCameraGrabFunc func, gpointer user_data); |