android: camera_device: Fix camera blocked issue when stopping capture
diff mbox series

Message ID 20240304094917.1144992-1-hui.fang@nxp.com
State New
Headers show
Series
  • android: camera_device: Fix camera blocked issue when stopping capture
Related show

Commit Message

Hui Fang March 4, 2024, 9:49 a.m. UTC
From: Anle Pan <anle.pan@nxp.com>

The issue occurs when stopping capture soon after starting capture.

In this case, no frame get from the device, the
related capture request has been pushed to the
queue descriptors_, but the queuedRequests_ was
still empty due to no requests will be queue to
the device since the stream will be stopped soon,
so there will be no camera->requestComplete called
later, then the descriptors_ can not pop normally,
this will cause the pending if we want to start capture next time.

To fix the issue, ensure the descriptors_ is
empty after the camera device is stopped.

Signed-off-by: Anle Pan <anle.pan@nxp.com>
---
 src/android/camera_device.cpp | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/src/android/camera_device.cpp b/src/android/camera_device.cpp
index 25cedd44..d452992d 100644
--- a/src/android/camera_device.cpp
+++ b/src/android/camera_device.cpp
@@ -433,8 +433,11 @@  void CameraDevice::flush()
 void CameraDevice::stop()
 {
 	MutexLocker stateLock(stateMutex_);
-	if (state_ == State::Stopped)
+	if (state_ == State::Stopped) {
+		MutexLocker descriptorsLock(descriptorsMutex_);
+		descriptors_ = {};
 		return;
+	}
 
 	camera_->stop();