summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2015-03-30 17:09:18 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2015-03-30 17:09:18 +0200
commitbf8ba2795bbf35f247c04656b2860d7ba4b9d660 (patch)
tree2bd9839e3bf7cb031751dbf19cae2a8e4c9c2090
parent2b8cfdd28ccee0fa7fbd1a1a2fd5f59f641a3285 (diff)
downloaduca-bf8ba2795bbf35f247c04656b2860d7ba4b9d660.tar.gz
uca-bf8ba2795bbf35f247c04656b2860d7ba4b9d660.tar.bz2
uca-bf8ba2795bbf35f247c04656b2860d7ba4b9d660.tar.xz
uca-bf8ba2795bbf35f247c04656b2860d7ba4b9d660.zip
ufo: start/stop pcilib only once
-rw-r--r--plugins/ufo/uca-ufo-camera.c17
1 files changed, 13 insertions, 4 deletions
diff --git a/plugins/ufo/uca-ufo-camera.c b/plugins/ufo/uca-ufo-camera.c
index 936485d..5c20517 100644
--- a/plugins/ufo/uca-ufo-camera.c
+++ b/plugins/ufo/uca-ufo-camera.c
@@ -248,6 +248,7 @@ setup_pcilib (UcaUfoCameraPrivate *priv)
{
pcilib_model_t model;
guint adc_resolution;
+ int err;
model = PCILIB_MODEL_DETECT;
priv->handle = pcilib_open("/dev/fpga0", model);
@@ -280,6 +281,15 @@ setup_pcilib (UcaUfoCameraPrivate *priv)
break;
}
+ err = pcilib_start(priv->handle, PCILIB_EVENT_DATA, PCILIB_EVENT_FLAGS_DEFAULT);
+
+ if (err != 0) {
+ g_set_error (&priv->construct_error,
+ UCA_UFO_CAMERA_ERROR, UCA_UFO_CAMERA_ERROR_INIT,
+ "pcilib start failed: %s", strerror (err));
+ return FALSE;
+ }
+
return TRUE;
}
@@ -340,8 +350,6 @@ uca_ufo_camera_start_recording(UcaCamera *camera, GError **error)
"trigger-mode", &trigger,
NULL);
- err = pcilib_start(priv->handle, PCILIB_EVENT_DATA, PCILIB_EVENT_FLAGS_DEFAULT);
- PCILIB_SET_ERROR(err, UCA_UFO_CAMERA_ERROR_START_RECORDING);
set_streaming (priv, trigger == UCA_CAMERA_TRIGGER_AUTO);
priv->timeout = (pcilib_timeout_t) (total_readout_time (UCA_UFO_CAMERA (camera)) * 1000 * 1000);
@@ -368,8 +376,6 @@ uca_ufo_camera_stop_recording(UcaCamera *camera, GError **error)
priv->async_thread = NULL;
}
- int err = pcilib_stop (priv->handle, PCILIB_EVENT_FLAGS_DEFAULT);
- PCILIB_SET_ERROR(err, UCA_UFO_CAMERA_ERROR_STOP_RECORDING);
set_streaming (priv, trigger != UCA_CAMERA_TRIGGER_AUTO);
}
@@ -610,6 +616,9 @@ uca_ufo_camera_finalize(GObject *object)
priv = UCA_UFO_CAMERA_GET_PRIVATE (object);
+ int err = pcilib_stop (priv->handle, PCILIB_EVENT_FLAGS_DEFAULT);
+ PCILIB_WARN_ON_ERROR (err);
+
pcilib_close (priv->handle);
g_clear_error (&priv->construct_error);