[libcamera-devel] [PATCH v2 3/4] libcamera: camera: add state machine to control access from applications
Niklas Söderlund
niklas.soderlund at ragnatech.se
Thu Feb 28 17:30:29 CET 2019
On 2019-02-28 03:16:25 +0100, Niklas Söderlund wrote:
[snip]
> diff --git a/src/libcamera/camera.cpp b/src/libcamera/camera.cpp
> index 84b97b5c2ce94ecf..4f0833300b9b7ffc 100644
> --- a/src/libcamera/camera.cpp
> +++ b/src/libcamera/camera.cpp
[snip]
> @@ -396,27 +549,22 @@ int Camera::start()
> * requests are cancelled and complete synchronously in an error state.
> *
> * \return 0 on success or a negative error code otherwise
> + * \retval -ENODEV The camera is no longer connected to the hardware
> + * \retval -EACCES The camera is not running so can't be stopped
> */
> int Camera::stop()
> {
> - int ret = exclusiveAccess();
> - if (ret)
> - return ret;
> + if (disconnected_)
> + return -ENODEV;
> +
> + if (!stateIs(CameraRunning))
> + return -EACCES;
>
> LOG(Camera, Debug) << "Stopping capture";
>
> pipe_->stop(this);
>
> - return 0;
> -}
> -
> -int Camera::exclusiveAccess()
> -{
> - if (disconnected_)
> - return -ENODEV;
> -
> - if (!acquired_)
> - return -EACCES;
> + state_ = CameraPrepared;
After a discussion on IRC it is agreed that the order of these
operations should be swapped for next version,
state_ = CameraPrepared;
pipe_->stop(this)
Instead of how this patch changes it,
pipe_->stop(this)
state_ = CameraPrepared;
>
> return 0;
> }
--
Regards,
Niklas Söderlund
More information about the libcamera-devel
mailing list