[PATCH] android: camera_device: Always clear descriptors_ in stop()

Jacopo Mondi jacopo.mondi at ideasonboard.com
Thu Apr 4 12:18:14 CEST 2024


From: Anle Pan <anle.pan at nxp.com>

When flush() is called and then a new stream configuration is set, the
descriptors_ queue might have a chance to be not cleared in stop(), as
the Camera is already in Stopped state.

This will prevent further requests from being completed in
sendCaptureResults() as the descriptors_ queue is not empty.

To fix the issue, clear the descriptors_ even if the Camera State is
Stopped. As a drawback the libcamera::Camera::stop() function might be
called twice, but this is allowed by the Camera state machine, and the
second call is guaranteed to be a nop.

Signed-off-by: Anle Pan <anle.pan at nxp.com>
Signed-off-by: Fang Hui <hui.fang at nxp.com>
Tested-by: Jacopo Mondi <jacopo.mondi at ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi at ideasonboard.com>
---

CTS shows no regressions compared to v0.2.0

---
 src/android/camera_device.cpp | 2 --
 1 file changed, 2 deletions(-)

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index d2679a9722e2..1b6f3f3a2b29 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -433,8 +433,6 @@ void CameraDevice::flush()
 void CameraDevice::stop()
 {
 	MutexLocker stateLock(stateMutex_);
-	if (state_ == State::Stopped)
-		return;

 	camera_->stop();

--
2.44.0



More information about the libcamera-devel mailing list