summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2011-04-26 16:00:13 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2011-04-26 16:00:13 +0200
commitb172726b7646f284560da670fe19ad28d88aaa15 (patch)
treeeb59a1be25c10645c594a0cb8dd4b90df699e4ba /src
parentfcffc9f40c32c863b85cbee3e7d6f51b5b6cdc41 (diff)
downloaduca-b172726b7646f284560da670fe19ad28d88aaa15.tar.gz
uca-b172726b7646f284560da670fe19ad28d88aaa15.tar.bz2
uca-b172726b7646f284560da670fe19ad28d88aaa15.tar.xz
uca-b172726b7646f284560da670fe19ad28d88aaa15.zip
Remove UCA_CAM_ERROR and handle correct recording states
Diffstat (limited to 'src')
-rw-r--r--src/cameras/pco.c12
-rw-r--r--src/cameras/pf.c2
-rw-r--r--src/uca-cam.h1
3 files changed, 11 insertions, 4 deletions
diff --git a/src/cameras/pco.c b/src/cameras/pco.c
index 6c4f93f..f6efd81 100644
--- a/src/cameras/pco.c
+++ b/src/cameras/pco.c
@@ -228,20 +228,25 @@ static uint32_t uca_pco_get_property(struct uca_camera *cam, enum uca_property_i
static uint32_t uca_pco_start_recording(struct uca_camera *cam)
{
uint32_t err = UCA_ERR_CAMERA | UCA_ERR_INIT;
+ if (cam->state == UCA_CAM_RECORDING)
+ return err | UCA_ERR_IS_RECORDING;
+
struct pco_edge *pco = GET_PCO(cam);
if (pco_arm_camera(pco) != PCO_NOERROR)
return err | UCA_ERR_UNCLASSIFIED;
if (pco_set_rec_state(pco, 1) != PCO_NOERROR)
return err | UCA_ERR_UNCLASSIFIED;
+
cam->state = UCA_CAM_RECORDING;
return cam->grabber->acquire(cam->grabber, -1);
}
static uint32_t uca_pco_stop_recording(struct uca_camera *cam)
{
- if (pco_set_rec_state(GET_PCO(cam), 0) != PCO_NOERROR)
+ if ((cam->state == UCA_CAM_RECORDING) && (pco_set_rec_state(GET_PCO(cam), 0) != PCO_NOERROR))
return UCA_ERR_CAMERA | UCA_ERR_INIT | UCA_ERR_UNCLASSIFIED;
- cam->state = UCA_CAM_ARMED;
+
+ cam->state = UCA_CAM_CONFIGURABLE;
return UCA_NO_ERROR;
}
@@ -255,6 +260,9 @@ static uint32_t uca_pco_trigger(struct uca_camera *cam)
static uint32_t uca_pco_grab(struct uca_camera *cam, char *buffer, void *meta_data)
{
+ if (cam->state != UCA_CAM_RECORDING)
+ return UCA_ERR_CAMERA | UCA_ERR_NOT_RECORDING;
+
uint16_t *frame;
uint32_t err = cam->grabber->grab(cam->grabber, (void **) &frame, &cam->current_frame);
if (err != UCA_NO_ERROR)
diff --git a/src/cameras/pf.c b/src/cameras/pf.c
index aa05df6..5a87380 100644
--- a/src/cameras/pf.c
+++ b/src/cameras/pf.c
@@ -233,7 +233,7 @@ uint32_t uca_pf_init(struct uca_camera **cam, struct uca_grabber *grabber)
val = UCA_FORMAT_GRAY8;
grabber->set_property(grabber, UCA_GRABBER_FORMAT, &val);
- val = UCA_TRIGGER_FREERUN;
+ val = UCA_TRIGGER_AUTO;
grabber->set_property(grabber, UCA_GRABBER_TRIGGER_MODE, &val);
uca_pf_get_property(uca, UCA_PROP_WIDTH, &uca->frame_width, 0);
diff --git a/src/uca-cam.h b/src/uca-cam.h
index e582066..ba5e101 100644
--- a/src/uca-cam.h
+++ b/src/uca-cam.h
@@ -23,7 +23,6 @@ enum uca_property_ids;
* Describes the current state of the camera.
*/
enum uca_cam_state {
- UCA_CAM_ERROR, /**< Camera is not working correctly */
UCA_CAM_CONFIGURABLE, /**< Camera can be configured and is not recording */
UCA_CAM_ARMED, /**< Camera is ready for recording */
UCA_CAM_RECORDING, /**< Camera is currently recording */