diff options
author | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2015-03-30 17:09:18 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2015-03-30 17:09:18 +0200 |
commit | bf8ba2795bbf35f247c04656b2860d7ba4b9d660 (patch) | |
tree | 2bd9839e3bf7cb031751dbf19cae2a8e4c9c2090 /plugins/ufo/uca-ufo-camera.c | |
parent | 2b8cfdd28ccee0fa7fbd1a1a2fd5f59f641a3285 (diff) | |
download | libuca-bf8ba2795bbf35f247c04656b2860d7ba4b9d660.tar.gz libuca-bf8ba2795bbf35f247c04656b2860d7ba4b9d660.tar.bz2 libuca-bf8ba2795bbf35f247c04656b2860d7ba4b9d660.tar.xz libuca-bf8ba2795bbf35f247c04656b2860d7ba4b9d660.zip |
ufo: start/stop pcilib only once
Diffstat (limited to 'plugins/ufo/uca-ufo-camera.c')
-rw-r--r-- | plugins/ufo/uca-ufo-camera.c | 17 |
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); |