summaryrefslogtreecommitdiffstats
path: root/plugins
diff options
context:
space:
mode:
Diffstat (limited to 'plugins')
-rw-r--r--plugins/mock/uca-mock-camera.c18
-rw-r--r--plugins/pco/uca-pco-camera.c23
-rw-r--r--plugins/pf/uca-pf-camera.c24
-rw-r--r--plugins/ufo/uca-ufo-camera.c38
4 files changed, 56 insertions, 47 deletions
diff --git a/plugins/mock/uca-mock-camera.c b/plugins/mock/uca-mock-camera.c
index c7561ab..675d5ec 100644
--- a/plugins/mock/uca-mock-camera.c
+++ b/plugins/mock/uca-mock-camera.c
@@ -242,20 +242,18 @@ uca_mock_camera_trigger (UcaCamera *camera, GError **error)
{
}
-static void
-uca_mock_camera_grab (UcaCamera *camera, gpointer *data, GError **error)
+static gboolean
+uca_mock_camera_grab (UcaCamera *camera, gpointer data, GError **error)
{
- g_return_if_fail(UCA_IS_MOCK_CAMERA(camera));
- g_return_if_fail(data != NULL);
+ g_return_val_if_fail (UCA_IS_MOCK_CAMERA(camera), FALSE);
- UcaMockCameraPrivate *priv = UCA_MOCK_CAMERA_GET_PRIVATE(camera);
+ UcaMockCameraPrivate *priv = UCA_MOCK_CAMERA_GET_PRIVATE (camera);
- if (*data == NULL)
- *data = g_malloc0(priv->roi_width * priv->roi_height);
-
- g_memmove(*data, priv->dummy_data, priv->roi_width * priv->roi_height);
- print_current_frame(priv, *data);
+ g_memmove (data, priv->dummy_data, priv->roi_width * priv->roi_height);
+ print_current_frame (priv, data);
priv->current_frame++;
+
+ return TRUE;
}
static void
diff --git a/plugins/pco/uca-pco-camera.c b/plugins/pco/uca-pco-camera.c
index de68001..4a0cce6 100644
--- a/plugins/pco/uca-pco-camera.c
+++ b/plugins/pco/uca-pco-camera.c
@@ -565,12 +565,12 @@ uca_pco_camera_trigger(UcaCamera *camera, GError **error)
"Could not trigger frame acquisition");
}
-static void
-uca_pco_camera_grab(UcaCamera *camera, gpointer *data, GError **error)
+static gboolean
+uca_pco_camera_grab(UcaCamera *camera, gpointer data, GError **error)
{
static const gint MAX_TIMEOUT = 5;
- g_return_if_fail(UCA_IS_PCO_CAMERA(camera));
+ g_return_val_if_fail (UCA_IS_PCO_CAMERA(camera), FALSE);
UcaPcoCameraPrivate *priv = UCA_PCO_CAMERA_GET_PRIVATE(camera);
gboolean is_readout = FALSE;
@@ -580,7 +580,7 @@ uca_pco_camera_grab(UcaCamera *camera, gpointer *data, GError **error)
if (priv->current_image == priv->num_recorded_images) {
g_set_error (error, UCA_CAMERA_ERROR, UCA_CAMERA_ERROR_END_OF_STREAM,
"End of data stream");
- return;
+ return FALSE;
}
/*
@@ -595,19 +595,20 @@ uca_pco_camera_grab(UcaCamera *camera, gpointer *data, GError **error)
priv->last_frame = Fg_getLastPicNumberBlockingEx(priv->fg, priv->last_frame + 1, priv->fg_port, MAX_TIMEOUT, priv->fg_mem);
if (priv->last_frame <= 0) {
- guint err = FG_OK + 1;
- FG_SET_ERROR(err, priv->fg, UCA_PCO_CAMERA_ERROR_FG_GENERAL);
+ g_set_error (error, UCA_PCO_CAMERA_ERROR,
+ UCA_PCO_CAMERA_ERROR_FG_GENERAL,
+ "%s", Fg_getLastErrorDescription(priv->fg));
+ return FALSE;
}
guint16 *frame = Fg_getImagePtrEx(priv->fg, priv->last_frame, priv->fg_port, priv->fg_mem);
- if (*data == NULL)
- *data = g_malloc0(priv->frame_width * priv->frame_height * priv->num_bytes);
-
if (priv->description->type == CAMERATYPE_PCO_EDGE)
- pco_get_reorder_func(priv->pco)((guint16 *) *data, frame, priv->frame_width, priv->frame_height);
+ pco_get_reorder_func(priv->pco)((guint16 *) data, frame, priv->frame_width, priv->frame_height);
else
- memcpy((gchar *) *data, (gchar *) frame, priv->frame_width * priv->frame_height * priv->num_bytes);
+ memcpy((gchar *) data, (gchar *) frame, priv->frame_width * priv->frame_height * priv->num_bytes);
+
+ return TRUE;
}
static void
diff --git a/plugins/pf/uca-pf-camera.c b/plugins/pf/uca-pf-camera.c
index 085fde5..b7967be 100644
--- a/plugins/pf/uca-pf-camera.c
+++ b/plugins/pf/uca-pf-camera.c
@@ -184,25 +184,27 @@ uca_pf_camera_start_readout(UcaCamera *camera, GError **error)
"This photon focus camera does not support recording to internal memory");
}
-static void
-uca_pf_camera_grab(UcaCamera *camera, gpointer *data, GError **error)
+static gboolean
+uca_pf_camera_grab(UcaCamera *camera, gpointer data, GError **error)
{
- g_return_if_fail(UCA_IS_PF_CAMERA(camera));
+ g_return_val_if_fail (UCA_IS_PF_CAMERA (camera), FALSE);
UcaPfCameraPrivate *priv = UCA_PF_CAMERA_GET_PRIVATE(camera);
- priv->last_frame = Fg_getLastPicNumberBlockingEx(priv->fg, priv->last_frame+1, priv->fg_port, 5, priv->fg_mem);
+ priv->last_frame = Fg_getLastPicNumberBlockingEx (priv->fg, priv->last_frame+1,
+ priv->fg_port, 5, priv->fg_mem);
if (priv->last_frame <= 0) {
- guint err = FG_OK + 1;
- FG_SET_ERROR(err, priv->fg, UCA_PF_CAMERA_ERROR_FG_GENERAL);
+ g_set_error (error, UCA_PF_CAMERA_ERROR,
+ UCA_PF_CAMERA_ERROR_FG_ACQUISITION,
+ "%s", Fg_getLastErrorDescription(priv->fg));
+ return FALSE;
}
- guint16 *frame = Fg_getImagePtrEx(priv->fg, priv->last_frame, priv->fg_port, priv->fg_mem);
-
- if (*data == NULL)
- *data = g_malloc0(priv->roi_width * priv->roi_height);
+ guint16 *frame = Fg_getImagePtrEx (priv->fg, priv->last_frame,
+ priv->fg_port, priv->fg_mem);
- memcpy((gchar *) *data, (gchar *) frame, priv->roi_width * priv->roi_height);
+ memcpy((gchar *) data, (gchar *) frame, priv->roi_width * priv->roi_height);
+ return TRUE;
}
static void
diff --git a/plugins/ufo/uca-ufo-camera.c b/plugins/ufo/uca-ufo-camera.c
index f68614e..93c13a8 100644
--- a/plugins/ufo/uca-ufo-camera.c
+++ b/plugins/ufo/uca-ufo-camera.c
@@ -34,6 +34,15 @@
return; \
}
+#define PCILIB_SET_ERROR_RETURN_FALSE(err, err_type) \
+ if (err != 0) { \
+ g_set_error(error, UCA_UFO_CAMERA_ERROR, \
+ err_type, \
+ "%s:%i pcilib: %s (errcode = %d)", \
+ __FILE__, __LINE__, strerror(err), err);\
+ return FALSE; \
+ }
+
#define UCA_UFO_CAMERA_GET_PRIVATE(obj) (G_TYPE_INSTANCE_GET_PRIVATE((obj), UCA_TYPE_UFO_CAMERA, UcaUfoCameraPrivate))
static void uca_ufo_camera_initable_iface_init (GInitableIface *iface);
@@ -301,10 +310,10 @@ uca_ufo_camera_stop_readout(UcaCamera *camera, GError **error)
g_return_if_fail(UCA_IS_UFO_CAMERA(camera));
}
-static void
-uca_ufo_camera_grab(UcaCamera *camera, gpointer *data, GError **error)
+static gboolean
+uca_ufo_camera_grab(UcaCamera *camera, gpointer data, GError **error)
{
- g_return_if_fail(UCA_IS_UFO_CAMERA(camera));
+ g_return_val_if_fail (UCA_IS_UFO_CAMERA(camera), FALSE);
UcaUfoCameraPrivate *priv = UCA_UFO_CAMERA_GET_PRIVATE(camera);
pcilib_event_id_t event_id;
pcilib_event_info_t event_info;
@@ -313,20 +322,17 @@ uca_ufo_camera_grab(UcaCamera *camera, gpointer *data, GError **error)
const gsize size = SENSOR_WIDTH * SENSOR_HEIGHT * sizeof(guint16);
if (priv->trigger != UCA_CAMERA_TRIGGER_EXTERNAL) {
- err = pcilib_trigger(priv->handle, PCILIB_EVENT0, 0, NULL);
- PCILIB_SET_ERROR(err, UCA_UFO_CAMERA_ERROR_TRIGGER);
+ err = pcilib_trigger (priv->handle, PCILIB_EVENT0, 0, NULL);
+ PCILIB_SET_ERROR_RETURN_FALSE (err, UCA_UFO_CAMERA_ERROR_TRIGGER);
}
- 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);
+ err = pcilib_get_next_event (priv->handle, priv->timeout, &event_id, sizeof(pcilib_event_info_t), &event_info);
+ PCILIB_SET_ERROR_RETURN_FALSE (err, UCA_UFO_CAMERA_ERROR_NEXT_EVENT);
- if (*data == NULL)
- *data = g_malloc0(SENSOR_WIDTH * SENSOR_HEIGHT * sizeof(guint16));
-
- gpointer src = pcilib_get_data(priv->handle, event_id, PCILIB_EVENT_DATA, (size_t *) &err);
+ gpointer src = pcilib_get_data (priv->handle, event_id, PCILIB_EVENT_DATA, (size_t *) &err);
if (src == NULL)
- PCILIB_SET_ERROR(err, UCA_UFO_CAMERA_ERROR_NO_DATA);
+ PCILIB_SET_ERROR_RETURN_FALSE (err, UCA_UFO_CAMERA_ERROR_NO_DATA);
/*
* Apparently, we checked that err equals total size in previous version.
@@ -336,15 +342,17 @@ uca_ufo_camera_grab(UcaCamera *camera, gpointer *data, GError **error)
*/
/* assert(err == size); */
- memcpy(*data, src, size);
+ memcpy (data, src, size);
/*
* Another problem here. What does this help us? At this point we have
* already overwritten the original buffer but can only know here if the
* data is corrupted.
*/
- err = pcilib_return_data(priv->handle, event_id, PCILIB_EVENT_DATA, data);
- PCILIB_SET_ERROR(err, UCA_UFO_CAMERA_ERROR_MAYBE_CORRUPTED);
+ err = pcilib_return_data (priv->handle, event_id, PCILIB_EVENT_DATA, data);
+ PCILIB_SET_ERROR_RETURN_FALSE (err, UCA_UFO_CAMERA_ERROR_MAYBE_CORRUPTED);
+
+ return TRUE;
}
static void