summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2012-08-07 14:40:38 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@gmail.com>2012-08-07 15:46:21 +0200
commit399ff33fe9ee40867486df64f50f129c88501daa (patch)
treee4ca3587ba8d95cff34064883e07e56a440fac5f /src
parent91a50f1a16c253bbc147cb2ccb120b6cd35e2ac4 (diff)
downloadlibuca-399ff33fe9ee40867486df64f50f129c88501daa.tar.gz
libuca-399ff33fe9ee40867486df64f50f129c88501daa.tar.bz2
libuca-399ff33fe9ee40867486df64f50f129c88501daa.tar.xz
libuca-399ff33fe9ee40867486df64f50f129c88501daa.zip
Calculate timeout only when recording starts
Reading register values is not really fast, so we keep the last exposure time when starting the acquisition.
Diffstat (limited to 'src')
-rw-r--r--src/cameras/uca-ufo-camera.c26
1 files changed, 15 insertions, 11 deletions
diff --git a/src/cameras/uca-ufo-camera.c b/src/cameras/uca-ufo-camera.c
index 5e17937..b17e417 100644
--- a/src/cameras/uca-ufo-camera.c
+++ b/src/cameras/uca-ufo-camera.c
@@ -93,9 +93,10 @@ static guint N_PROPERTIES;
static GHashTable *ufo_property_table; /* maps from prop_id to RegisterInfo* */
struct _UcaUfoCameraPrivate {
- pcilib_t *handle;
- guint n_bits;
- guint bit_mode;
+ pcilib_t *handle;
+ pcilib_timeout_t timeout;
+ guint n_bits;
+ guint bit_mode;
};
static void
@@ -224,16 +225,24 @@ UcaUfoCamera *uca_ufo_camera_new(GError **error)
static void uca_ufo_camera_start_recording(UcaCamera *camera, GError **error)
{
+ UcaUfoCameraPrivate *priv;
+ gdouble exposure_time;
+ int err;
+
g_return_if_fail(UCA_IS_UFO_CAMERA(camera));
- UcaUfoCameraPrivate *priv = UCA_UFO_CAMERA_GET_PRIVATE(camera);
- int err = pcilib_start(priv->handle, PCILIB_EVENT_DATA, PCILIB_EVENT_FLAGS_DEFAULT);
+
+ priv = UCA_UFO_CAMERA_GET_PRIVATE(camera);
+ 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,
+ "exposure-time", &exposure_time,
NULL);
+ priv->timeout = ((pcilib_timeout_t) (exposure_time * 1000 + 50.0) * 1000);
+
if (transfer_async) {
pcilib_trigger(priv->handle, PCILIB_EVENT0, 0, NULL);
pcilib_stream(priv->handle, &event_callback, camera);
@@ -261,8 +270,6 @@ static void uca_ufo_camera_grab(UcaCamera *camera, gpointer *data, GError **erro
UcaUfoCameraPrivate *priv = UCA_UFO_CAMERA_GET_PRIVATE(camera);
pcilib_event_id_t event_id;
pcilib_event_info_t event_info;
- pcilib_timeout_t timeout;
- gdouble exposure_time;
size_t err;
const gsize size = SENSOR_WIDTH * SENSOR_HEIGHT * sizeof(guint16);
@@ -270,10 +277,7 @@ static void uca_ufo_camera_grab(UcaCamera *camera, gpointer *data, GError **erro
err = pcilib_trigger(priv->handle, PCILIB_EVENT0, 0, NULL);
PCILIB_SET_ERROR(err, UCA_UFO_CAMERA_ERROR_TRIGGER);
- g_object_get (G_OBJECT (camera), "exposure-time", &exposure_time, NULL);
- timeout = ((pcilib_timeout_t) (exposure_time * 1000 + 50.0) * 1000);
-
- err = pcilib_get_next_event(priv->handle, timeout, &event_id, sizeof(pcilib_event_info_t), &event_info);
+ err = pcilib_get_next_event(priv->handle, priv->timeout, &event_id, sizeof(pcilib_event_info_t), &event_info);
PCILIB_SET_ERROR(err, UCA_UFO_CAMERA_ERROR_NEXT_EVENT);
if (*data == NULL)