diff options
author | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-04-17 16:49:47 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@gmail.com> | 2012-04-17 16:49:47 +0200 |
commit | 6c0869b16849ac665c49a055ae48985485b9fa04 (patch) | |
tree | 86b31c0215132af56551addba1349cd05ac09cd3 | |
parent | 435855dffba54084c9df5c3521cb0b41fd5086df (diff) | |
download | uca-6c0869b16849ac665c49a055ae48985485b9fa04.tar.gz uca-6c0869b16849ac665c49a055ae48985485b9fa04.tar.bz2 uca-6c0869b16849ac665c49a055ae48985485b9fa04.tar.xz uca-6c0869b16849ac665c49a055ae48985485b9fa04.zip |
Implement asynchronous recording
-rw-r--r-- | src/cameras/uca-ufo-camera.c | 31 |
1 files changed, 30 insertions, 1 deletions
diff --git a/src/cameras/uca-ufo-camera.c b/src/cameras/uca-ufo-camera.c index e642605..43d0454 100644 --- a/src/cameras/uca-ufo-camera.c +++ b/src/cameras/uca-ufo-camera.c @@ -95,6 +95,26 @@ static void ignore_messages(const char *format, ...) { } +static int event_callback(pcilib_event_id_t event_id, pcilib_event_info_t *info, void *user) +{ + UcaCamera *camera = UCA_CAMERA(user); + UcaUfoCameraPrivate *priv = UCA_UFO_CAMERA_GET_PRIVATE(camera); + size_t error = 0; + + void *buffer = pcilib_get_data(priv->handle, event_id, PCILIB_EVENT_DATA, &error); + + if (buffer == NULL) { + pcilib_trigger(priv->handle, PCILIB_EVENT0, 0, NULL); + return PCILIB_STREAMING_CONTINUE; + } + + camera->grab_func(buffer, camera->user_data); + pcilib_return_data(priv->handle, event_id, PCILIB_EVENT_DATA, buffer); + pcilib_trigger(priv->handle, PCILIB_EVENT0, 0, NULL); + + return PCILIB_STREAMING_CONTINUE; +} + UcaUfoCamera *uca_ufo_camera_new(GError **error) { pcilib_model_t model = PCILIB_MODEL_DETECT; @@ -110,7 +130,6 @@ UcaUfoCamera *uca_ufo_camera_new(GError **error) UcaUfoCamera *camera = g_object_new(UCA_TYPE_UFO_CAMERA, NULL); UcaUfoCameraPrivate *priv = UCA_UFO_CAMERA_GET_PRIVATE(camera); - priv->handle = handle; return camera; @@ -122,6 +141,16 @@ static void uca_ufo_camera_start_recording(UcaCamera *camera, GError **error) UcaUfoCameraPrivate *priv = UCA_UFO_CAMERA_GET_PRIVATE(camera); int err = pcilib_start(priv->handle, PCILIB_EVENT_DATA, PCILIB_EVENT_FLAGS_DEFAULT); PCILIB_SET_ERROR(err, UCA_UFO_CAMERA_ERROR_START_RECORDING); + + gboolean transfer_async = FALSE; + g_object_get(G_OBJECT(camera), + "transfer-asynchronously", &transfer_async, + NULL); + + if (transfer_async) { + pcilib_trigger(priv->handle, PCILIB_EVENT0, 0, NULL); + pcilib_stream(priv->handle, &event_callback, camera); + } } static void uca_ufo_camera_stop_recording(UcaCamera *camera, GError **error) |