[libcamera-devel] [PATCH v5 1/2] android: CameraDevice: Add stop()
Hirokazu Honda
hiroh at chromium.org
Fri Apr 2 04:12:37 CEST 2021
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>
---
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,
--
2.31.0.208.g409f899ff0-goog
More information about the libcamera-devel
mailing list