summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/cameras/pf.c30
-rw-r--r--test/control.c4
2 files changed, 19 insertions, 15 deletions
diff --git a/src/cameras/pf.c b/src/cameras/pf.c
index a653b99..48f2192 100644
--- a/src/cameras/pf.c
+++ b/src/cameras/pf.c
@@ -39,21 +39,31 @@ static struct uca_pf_map uca_to_pf[] = {
{ -1, NULL }
};
+static int uca_pf_set_uint32_property(TOKEN token, void *data, uint32_t *update_var)
+{
+ PFValue value;
+ value.type = PF_INT;
+ value.value.i = *((uint32_t *) data);
+ if (update_var != NULL)
+ *update_var = value.value.i;
+ return pfDevice_SetProperty(0, token, &value);
+}
+
static uint32_t uca_pf_set_property(struct uca_camera *cam, enum uca_property_ids property, void *data)
{
struct uca_grabber *grabber = cam->grabber;
- TOKEN t = INVALID_TOKEN;
+ TOKEN token = INVALID_TOKEN;
int i = 0;
/* Find a valid pf token for the property */
while (uca_to_pf[i].uca_prop != -1) {
if (uca_to_pf[i].uca_prop == property) {
- t = pfProperty_ParseName(0, uca_to_pf[i].pf_prop);
+ token = pfProperty_ParseName(0, uca_to_pf[i].pf_prop);
break;
}
i++;
}
- if (t == INVALID_TOKEN)
+ if (token == INVALID_TOKEN)
return UCA_ERR_PROP_INVALID;
PFValue value;
@@ -62,23 +72,15 @@ static uint32_t uca_pf_set_property(struct uca_camera *cam, enum uca_property_id
case UCA_PROP_WIDTH:
if (grabber->set_property(grabber, UCA_GRABBER_WIDTH, (uint32_t *) data) != UCA_NO_ERROR)
return UCA_ERR_PROP_VALUE_OUT_OF_RANGE;
-
- value.value.i = *((uint32_t *) data);
- if (pfDevice_SetProperty(0, t, &value) < 0)
+ if (uca_pf_set_uint32_property(token, data, &cam->frame_width) < 0)
return UCA_ERR_PROP_VALUE_OUT_OF_RANGE;
-
- cam->frame_width = value.value.i;
break;
case UCA_PROP_HEIGHT:
if (grabber->set_property(grabber, UCA_GRABBER_HEIGHT, (uint32_t *) data) != UCA_NO_ERROR)
return UCA_ERR_PROP_VALUE_OUT_OF_RANGE;
-
- value.value.i = *((uint32_t *) data);
- if (pfDevice_SetProperty(0, t, &value) < 0)
+ if (uca_pf_set_uint32_property(token, data, &cam->frame_height) < 0)
return UCA_ERR_PROP_VALUE_OUT_OF_RANGE;
-
- cam->frame_height = value.value.i;
break;
case UCA_PROP_X_OFFSET:
@@ -96,7 +98,7 @@ static uint32_t uca_pf_set_property(struct uca_camera *cam, enum uca_property_id
* seconds. We also by-pass the frame grabber... */
value.type = PF_FLOAT;
value.value.f = (float) *((uint32_t *) data) / 1000.0;
- if (pfDevice_SetProperty(0, t, &value) < 0)
+ if (pfDevice_SetProperty(0, token, &value) < 0)
return UCA_ERR_PROP_VALUE_OUT_OF_RANGE;
break;
diff --git a/test/control.c b/test/control.c
index dcb8c8e..7f013e2 100644
--- a/test/control.c
+++ b/test/control.c
@@ -336,8 +336,10 @@ int main(int argc, char *argv[])
/* start grabbing and thread */
int pixel_size = bits_per_sample == 8 ? 1 : 2;
+ if (uca_cam_alloc(cam, 20) != UCA_NO_ERROR)
+ g_print("Couldn't allocate buffer for 20 frames\n");
+
ThreadData td;
- uca_cam_alloc(cam, 20);
td.image = image;
td.pixbuf = pixbuf;
td.buffer = (guchar *) g_malloc(pixel_size * width * height);