summaryrefslogtreecommitdiffstats
path: root/src/grabbers
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2011-03-23 12:35:19 +0100
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2011-03-23 12:35:19 +0100
commitff7f2398283f5059e3b8e0149e0582ee7d30ad21 (patch)
tree598637736b0c8164dabad2c163b01816279f0051 /src/grabbers
parent6c822e1dedff95eeb64733e8ae0f7554b01bcd17 (diff)
downloaduca-ff7f2398283f5059e3b8e0149e0582ee7d30ad21.tar.gz
uca-ff7f2398283f5059e3b8e0149e0582ee7d30ad21.tar.bz2
uca-ff7f2398283f5059e3b8e0149e0582ee7d30ad21.tar.xz
uca-ff7f2398283f5059e3b8e0149e0582ee7d30ad21.zip
Use more flexible error codes
Diffstat (limited to 'src/grabbers')
-rw-r--r--src/grabbers/me4.c33
1 files changed, 19 insertions, 14 deletions
diff --git a/src/grabbers/me4.c b/src/grabbers/me4.c
index 6cd72ae..01b908d 100644
--- a/src/grabbers/me4.c
+++ b/src/grabbers/me4.c
@@ -72,9 +72,10 @@ static struct uca_sisofg_map_t *uca_me4_find_property(enum uca_grabber_constants
uint32_t uca_me4_set_property(struct uca_grabber *grabber, enum uca_grabber_constants property, void *data)
{
+ uint32_t err = UCA_ERR_GRABBER | UCA_ERR_PROP;
struct uca_sisofg_map_t *fg_prop = uca_me4_find_property(property);
if (fg_prop == NULL)
- return UCA_ERR_PROP_INVALID;
+ return err | UCA_ERR_INVALID;
switch (property) {
case UCA_GRABBER_TIMEOUT:
@@ -91,21 +92,25 @@ uint32_t uca_me4_set_property(struct uca_grabber *grabber, enum uca_grabber_cons
* the map. */
struct uca_sisofg_map_t *constant = uca_me4_find_property(*((uint32_t *) data));
if (constant != NULL)
- return Fg_setParameter(GET_FG(grabber), fg_prop->fg_id, &constant->fg_id, PORT_A) == FG_OK ? UCA_NO_ERROR : UCA_ERR_PROP_INVALID;
- return UCA_ERR_PROP_INVALID;
+ return Fg_setParameter(GET_FG(grabber), fg_prop->fg_id, &constant->fg_id, PORT_A) == FG_OK ? \
+ UCA_NO_ERROR : err | UCA_ERR_INVALID;
+ return err | UCA_ERR_INVALID;
}
else
- return Fg_setParameter(GET_FG(grabber), fg_prop->fg_id, data, PORT_A) == FG_OK ? UCA_NO_ERROR : UCA_ERR_PROP_GENERAL;
+ return Fg_setParameter(GET_FG(grabber), fg_prop->fg_id, data, PORT_A) == FG_OK ? \
+ UCA_NO_ERROR : err | UCA_ERR_INVALID;
}
uint32_t uca_me4_get_property(struct uca_grabber *grabber, enum uca_grabber_constants property, void *data)
{
+ uint32_t err = UCA_ERR_GRABBER | UCA_ERR_PROP;
struct uca_sisofg_map_t *fg_prop = uca_me4_find_property(property);
if (fg_prop == NULL)
- return UCA_ERR_PROP_INVALID;
+ return err | UCA_ERR_INVALID;
/* FIXME: translate data back to UCA_ normalized constants */
- return Fg_getParameter(GET_FG(grabber), fg_prop->fg_id, data, PORT_A) == FG_OK ? UCA_NO_ERROR : UCA_ERR_PROP_GENERAL;
+ return Fg_getParameter(GET_FG(grabber), fg_prop->fg_id, data, PORT_A) == FG_OK ? \
+ UCA_NO_ERROR : err | UCA_ERR_INVALID;
}
uint32_t uca_me4_alloc(struct uca_grabber *grabber, uint32_t pixel_size, uint32_t n_buffers)
@@ -125,27 +130,27 @@ uint32_t uca_me4_alloc(struct uca_grabber *grabber, uint32_t pixel_size, uint32_
((struct fg_apc_data *) grabber->user)->mem = mem;
return UCA_NO_ERROR;
}
- return UCA_ERR_PROP_GENERAL;
+ return UCA_ERR_GRABBER | UCA_ERR_NO_MEMORY;
}
uint32_t uca_me4_acquire(struct uca_grabber *grabber, int32_t n_frames)
{
if (GET_MEM(grabber) == NULL)
- return UCA_ERR_GRABBER_NOMEM;
+ return UCA_ERR_GRABBER | UCA_ERR_NO_MEMORY;
int flag = grabber->asynchronous ? ACQ_STANDARD : ACQ_BLOCK;
n_frames = n_frames < 0 ? GRAB_INFINITE : n_frames;
if (Fg_AcquireEx(GET_FG(grabber), 0, n_frames, flag, GET_MEM(grabber)) == FG_OK)
return UCA_NO_ERROR;
- return UCA_ERR_GRABBER_ACQUIRE;
+ return UCA_ERR_GRABBER | UCA_ERR_ACQUIRE;
}
uint32_t uca_me4_stop_acquire(struct uca_grabber *grabber)
{
if (GET_MEM(grabber) != NULL)
if (Fg_stopAcquireEx(GET_FG(grabber), 0, GET_MEM(grabber), STOP_SYNC) != FG_OK)
- return UCA_ERR_PROP_GENERAL;
+ return UCA_ERR_GRABBER | UCA_ERR_ACQUIRE;
return UCA_NO_ERROR;
}
@@ -160,7 +165,7 @@ uint32_t uca_me4_grab(struct uca_grabber *grabber, void **buffer, uint64_t *fram
last_frame = Fg_getLastPicNumberBlockingEx(me4->fg, last_frame+1, PORT_A, me4->timeout, me4->mem);
if (last_frame <= 0)
- return UCA_ERR_PROP_GENERAL;
+ return UCA_ERR_GRABBER | UCA_ERR_FRAME_TRANSFER;
*frame_number = (uint64_t) last_frame;
*buffer = Fg_getImagePtrEx(me4->fg, last_frame, PORT_A, me4->mem);
@@ -191,10 +196,10 @@ uint32_t uca_me4_register_callback(struct uca_grabber *grabber, uca_cam_grab_cal
ctrl.timeout = 1;
if (Fg_registerApcHandler(GET_FG(grabber), PORT_A, &ctrl, FG_APC_CONTROL_BASIC) != FG_OK)
- return UCA_ERR_GRABBER_CALLBACK_REGISTRATION_FAILED;
+ return UCA_ERR_GRABBER | UCA_ERR_CALLBACK;
}
else
- return UCA_ERR_GRABBER_CALLBACK_ALREADY_REGISTERED;
+ return UCA_ERR_GRABBER | UCA_ERR_CALLBACK;
return UCA_NO_ERROR;
}
@@ -203,7 +208,7 @@ uint32_t uca_me4_init(struct uca_grabber **grabber)
{
Fg_Struct *fg = Fg_Init("libFullAreaGray8.so", 0);
if (fg == NULL)
- return UCA_ERR_GRABBER_NOT_FOUND;
+ return UCA_ERR_GRABBER | UCA_ERR_NOT_FOUND;
struct uca_grabber *uca = (struct uca_grabber *) malloc(sizeof(struct uca_grabber));
memset(uca, 0, sizeof(struct uca_grabber));