[RFC,v1,14/54] v4l2: v4l2_camera: Always clear pending requests
diff mbox series

Message ID 20260629163017.863145-15-barnabas.pocze@ideasonboard.com
State New
Headers show
Series
  • libcamera: Split requests and buffers
Related show

Commit Message

Barnabás Pőcze June 29, 2026, 4:29 p.m. UTC
Clear the list of pending requests regardless whether the camera is running
or not. The list should only contain entries when `!isRunning_`, in which
case it was not cleared previously.

Consider the following scenario:

  * STREAMOFF
  * QBUF(10)
  * STREAMOFF
  // at this point buffer 10 should be dequeued;
  // but `pendingRequests_` would still have the request
  // that was added due to QBUF
  * QBUF(10)
  // `pendingRequests_` would have the same requests twice
  * STREAMON
  // the same request would be tried to be queued twice

Signed-off-by: Barnabás Pőcze <barnabas.pocze@ideasonboard.com>
Reviewed-by: Jacopo Mondi <jacopo.mondi@ideasonboard.com>
Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>
---
 src/v4l2/v4l2_camera.cpp | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

Patch
diff mbox series

diff --git a/src/v4l2/v4l2_camera.cpp b/src/v4l2/v4l2_camera.cpp
index e72b73a22a..8c7de8e92b 100644
--- a/src/v4l2/v4l2_camera.cpp
+++ b/src/v4l2/v4l2_camera.cpp
@@ -226,6 +226,8 @@  int V4L2Camera::streamOn()
 
 int V4L2Camera::streamOff()
 {
+	pendingRequests_.clear();
+
 	if (!isRunning_) {
 		for (std::unique_ptr<Request> &req : requestPool_)
 			req->reuse();
@@ -233,8 +235,6 @@  int V4L2Camera::streamOff()
 		return 0;
 	}
 
-	pendingRequests_.clear();
-
 	int ret = camera_->stop();
 	if (ret < 0)
 		return ret == -EACCES ? -EBUSY : ret;