[libcamera-devel] [PATCH v5 1/2] android: CameraDevice: Add stop()
Laurent Pinchart
laurent.pinchart at ideasonboard.com
Sat Apr 3 00:31:04 CEST 2021
Hi Hiro,
Thank you for the patch.
On Fri, Apr 02, 2021 at 11:12:37AM +0900, Hirokazu Honda wrote:
> This adds CameraDevice::stop(), which cleans up the member
> variables of CameraDevice. It is called in CameraDevice::close()
> and CameraDevice::configureStreams().
>
> Signed-off-by: Hirokazu Honda <hiroh at chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
> ---
> src/android/camera_device.cpp | 19 ++++++++++++-------
> src/android/camera_device.h | 2 ++
> 2 files changed, 14 insertions(+), 7 deletions(-)
>
> diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
> index eb327978..b45d3a54 100644
> --- a/src/android/camera_device.cpp
> +++ b/src/android/camera_device.cpp
> @@ -659,9 +659,18 @@ void CameraDevice::close()
> {
> streams_.clear();
>
> + stop();
> +
> + camera_->release();
> +}
> +
> +void CameraDevice::stop()
> +{
> + if (!running_)
> + return;
> +
> worker_.stop();
> camera_->stop();
> - camera_->release();
>
> running_ = false;
> }
> @@ -1547,12 +1556,8 @@ PixelFormat CameraDevice::toPixelFormat(int format) const
> */
> int CameraDevice::configureStreams(camera3_stream_configuration_t *stream_list)
> {
> - /* Before any configuration attempt, stop the camera if it's running. */
> - if (running_) {
> - worker_.stop();
> - camera_->stop();
> - running_ = false;
> - }
> + /* Before any configuration attempt, stop the camera. */
> + stop();
>
> /*
> * Generate an empty configuration, and construct a StreamConfiguration
> diff --git a/src/android/camera_device.h b/src/android/camera_device.h
> index 11bdfec8..39cf95ad 100644
> --- a/src/android/camera_device.h
> +++ b/src/android/camera_device.h
> @@ -85,6 +85,8 @@ private:
> int androidFormat;
> };
>
> + void stop();
> +
> int initializeStreamConfigurations();
> std::vector<libcamera::Size>
> getYUVResolutions(libcamera::CameraConfiguration *cameraConfig,
--
Regards,
Laurent Pinchart
More information about the libcamera-devel
mailing list