<div dir="ltr"><div dir="ltr">Hi Jacopo, thank you for the patch.</div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Thu, May 13, 2021 at 6:22 PM Jacopo Mondi <<a href="mailto:jacopo@jmondi.org">jacopo@jmondi.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">The CameraDevice class maintains the camera state in the 'running_'<br>
boolean flag to check if the camera has to be started at the first<br>
received process_capture_request() call which happens after the camera<br>
had been stopped.<br>
<br>
So far this was correct, as the operations that change the camera<br>
could only start or stop the camera, so a simple boolean flag<br>
was enough.<br>
<br>
To prepare to handle the flush() operation that will introduce a new<br>
'flushing' state, replace the simple plain boolean flag with an<br>
enumeration of values that define the CameraState.<br>
<br>
Signed-off-by: Jacopo Mondi <<a href="mailto:jacopo@jmondi.org" target="_blank">jacopo@jmondi.org</a>><br>
Reviewed-by: Niklas Söderlund <<a href="mailto:niklas.soderlund@ragnatech.se" target="_blank">niklas.soderlund@ragnatech.se</a>><br></blockquote><div><br></div><div>Reviewed-by: Hirokazu Honda <<a href="mailto:hiroh@chromium.org">hiroh@chromium.org</a>></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
---<br>
src/android/camera_device.cpp | 10 +++++-----<br>
src/android/camera_device.h | 8 +++++++-<br>
2 files changed, 12 insertions(+), 6 deletions(-)<br>
<br>
diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp<br>
index 383baa60f918..82dd7ce0ee99 100644<br>
--- a/src/android/camera_device.cpp<br>
+++ b/src/android/camera_device.cpp<br>
@@ -402,7 +402,7 @@ CameraDevice::Camera3RequestDescriptor::Camera3RequestDescriptor(<br>
*/<br>
<br>
CameraDevice::CameraDevice(unsigned int id, std::shared_ptr<Camera> camera)<br>
- : id_(id), running_(false), camera_(std::move(camera)),<br>
+ : id_(id), state_(CameraStopped), camera_(std::move(camera)),<br>
facing_(CAMERA_FACING_FRONT), orientation_(0)<br>
{<br>
camera_->requestCompleted.connect(this, &CameraDevice::requestComplete);<br>
@@ -758,14 +758,14 @@ void CameraDevice::close()<br>
<br>
void CameraDevice::stop()<br>
{<br>
- if (!running_)<br>
+ if (state_ == CameraStopped)<br>
return;<br>
<br>
worker_.stop();<br>
camera_->stop();<br>
<br>
descriptors_.clear();<br>
- running_ = false;<br>
+ state_ = CameraStopped;<br>
}<br>
<br>
void CameraDevice::setCallbacks(const camera3_callback_ops_t *callbacks)<br>
@@ -1915,7 +1915,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques<br>
return -EINVAL;<br>
<br>
/* Start the camera if that's the first request we handle. */<br>
- if (!running_) {<br>
+ if (state_ == CameraStopped) {<br>
worker_.start();<br>
<br>
int ret = camera_->start();<br>
@@ -1924,7 +1924,7 @@ int CameraDevice::processCaptureRequest(camera3_capture_request_t *camera3Reques<br>
return ret;<br>
}<br>
<br>
- running_ = true;<br>
+ state_ = CameraRunning;<br>
}<br>
<br>
/*<br>
diff --git a/src/android/camera_device.h b/src/android/camera_device.h<br>
index 8d5da8bc59e1..30b364decaab 100644<br>
--- a/src/android/camera_device.h<br>
+++ b/src/android/camera_device.h<br>
@@ -88,6 +88,11 @@ private:<br>
int androidFormat;<br>
};<br>
<br>
+ enum State {<br>
+ CameraStopped,<br>
+ CameraRunning,<br>
+ };<br>
+<br>
void stop();<br>
<br>
int initializeStreamConfigurations();<br>
@@ -115,7 +120,8 @@ private:<br>
<br>
CameraWorker worker_;<br>
<br>
- bool running_;<br>
+ State state_;<br>
+<br>
std::shared_ptr<libcamera::Camera> camera_;<br>
std::unique_ptr<libcamera::CameraConfiguration> config_;<br>
<br>
-- <br>
2.31.1<br>
<br>
_______________________________________________<br>
libcamera-devel mailing list<br>
<a href="mailto:libcamera-devel@lists.libcamera.org" target="_blank">libcamera-devel@lists.libcamera.org</a><br>
<a href="https://lists.libcamera.org/listinfo/libcamera-devel" rel="noreferrer" target="_blank">https://lists.libcamera.org/listinfo/libcamera-devel</a><br>
</blockquote></div></div>