diff options
author | Hirokazu Honda <hiroh@chromium.org> | 2021-04-02 11:12:37 +0900 |
---|---|---|
committer | Laurent Pinchart <laurent.pinchart@ideasonboard.com> | 2021-04-20 05:55:50 +0300 |
commit | 0b661d70ec62d69ffd4ea7bb0aeb92d7ad12b8d3 (patch) | |
tree | d62d0c83f8ef150f2d00769801ff45544fd2f1f8 /src | |
parent | 796109c8dcb133d85a30f12864d924b20dad5f5a (diff) |
android: CameraDevice: Add stop()
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@chromium.org>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r-- | src/android/camera_device.cpp | 19 | ||||
-rw-r--r-- | 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 89044efa..00eb76b5 100644 --- a/src/android/camera_device.cpp +++ b/src/android/camera_device.cpp @@ -754,9 +754,18 @@ void CameraDevice::close() { streams_.clear(); + stop(); + + camera_->release(); +} + +void CameraDevice::stop() +{ + if (!running_) + return; + worker_.stop(); camera_->stop(); - camera_->release(); running_ = false; } @@ -1642,12 +1651,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(); if (stream_list->num_streams == 0) { LOG(HAL, Error) << "No streams in configuration"; 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, |