summaryrefslogtreecommitdiffstats
path: root/src/uca.c
diff options
context:
space:
mode:
authorMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2011-04-27 09:00:22 +0200
committerMatthias Vogelgesang <matthias.vogelgesang@kit.edu>2011-04-27 09:00:22 +0200
commitc1b6c87c62f544fa6353bdb45bd9a21139eb1fa9 (patch)
treeeec71dc5dc39c57e132db637f8a616a1588b16b1 /src/uca.c
parent45cd588f12f485d4b3a44b425dcbbcdec5f833db (diff)
downloaduca-c1b6c87c62f544fa6353bdb45bd9a21139eb1fa9.tar.gz
uca-c1b6c87c62f544fa6353bdb45bd9a21139eb1fa9.tar.bz2
uca-c1b6c87c62f544fa6353bdb45bd9a21139eb1fa9.tar.xz
uca-c1b6c87c62f544fa6353bdb45bd9a21139eb1fa9.zip
Do state handling only once in uca.c instead of all camera implementations
Diffstat (limited to 'src/uca.c')
-rw-r--r--src/uca.c20
1 files changed, 18 insertions, 2 deletions
diff --git a/src/uca.c b/src/uca.c
index 4341a68..18f2786 100644
--- a/src/uca.c
+++ b/src/uca.c
@@ -278,18 +278,32 @@ uint32_t uca_cam_get_property(struct uca_camera *cam, enum uca_property_ids prop
uint32_t uca_cam_start_recording(struct uca_camera *cam)
{
struct uca_camera_priv *priv = cam->priv;
- return priv->start_recording(priv);
+ if (priv->state == UCA_CAM_RECORDING)
+ return UCA_ERR_CAMERA | UCA_ERR_CONFIGURATION | UCA_ERR_IS_RECORDING;
+
+ uint32_t err = priv->start_recording(priv);
+ if (err == UCA_NO_ERROR)
+ priv->state = UCA_CAM_RECORDING;
+ return err;
}
uint32_t uca_cam_stop_recording(struct uca_camera *cam)
{
struct uca_camera_priv *priv = cam->priv;
- return priv->stop_recording(priv);
+ if (priv->state != UCA_CAM_RECORDING)
+ return UCA_ERR_CAMERA | UCA_ERR_CONFIGURATION | UCA_ERR_NOT_RECORDING;
+
+ uint32_t err = priv->stop_recording(priv);
+ if (err == UCA_NO_ERROR)
+ priv->state = UCA_CAM_CONFIGURABLE;
+ return err;
}
uint32_t uca_cam_trigger(struct uca_camera *cam)
{
struct uca_camera_priv *priv = cam->priv;
+ if (priv->state != UCA_CAM_RECORDING)
+ return UCA_ERR_CAMERA | UCA_ERR_TRIGGER | UCA_ERR_NOT_RECORDING;
return priv->trigger(priv);
}
@@ -302,6 +316,8 @@ uint32_t uca_cam_register_callback(struct uca_camera *cam, uca_cam_grab_callback
uint32_t uca_cam_grab(struct uca_camera *cam, char *buffer, void *meta_data)
{
struct uca_camera_priv *priv = cam->priv;
+ if (priv->state != UCA_CAM_RECORDING)
+ return UCA_ERR_CAMERA | UCA_ERR_NOT_RECORDING;
return priv->grab(priv, buffer, meta_data);
}