diff options
author | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2011-04-27 09:00:22 +0200 |
---|---|---|
committer | Matthias Vogelgesang <matthias.vogelgesang@kit.edu> | 2011-04-27 09:00:22 +0200 |
commit | c1b6c87c62f544fa6353bdb45bd9a21139eb1fa9 (patch) | |
tree | eec71dc5dc39c57e132db637f8a616a1588b16b1 /src/uca.c | |
parent | 45cd588f12f485d4b3a44b425dcbbcdec5f833db (diff) | |
download | uca-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.c | 20 |
1 files changed, 18 insertions, 2 deletions
@@ -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); } |