[v2] libcamera: pipeline_handler: Fix requestComplete on waiting requests on stop
diff mbox series

Message ID 20251105135859.282979-1-stefan.klug@ideasonboard.com
State New
Headers show
Series
  • [v2] libcamera: pipeline_handler: Fix requestComplete on waiting requests on stop
Related show

Commit Message

Stefan Klug Nov. 5, 2025, 1:58 p.m. UTC
The requestComplete signal is not emitted when the camera is stopped and
the request is still in the waitingRequests_ queue. Fix that by calling
doQueueRequest() on the waiting requests after marking them as
cancelled. This ensures that the requests gets a proper sequence number
and are added to the queuedRequests_ list. This list is then iterated in
completeRequest() and leads to the requestComplete signal.

Closes: https://gitlab.freedesktop.org/camera/libcamera/-/issues/281
Signed-off-by: Stefan Klug <stefan.klug@ideasonboard.com>
Reviewed-by: Paul Elder <paul.elder@ideasonboard.com>

---

Hey all,

In the discussion on v1 https://patchwork.libcamera.org/patch/24719/ it
was rightly noted that the solution does feel a bit hacky. However there
was no clear better solution and it was also acknowledged that the
change is quite small and solves the problem. So I'd propose to merge it
in as long as there is no better proposal.

Changes in v2:
- Collected rby tag
- Added closes tag to automatically close the issue
- Slightly modified the comment and commit message to mention that this
  logic also ensures that the requests get a sequence number.

Best regards,
Stefan

---
 src/libcamera/pipeline_handler.cpp | 11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

Patch
diff mbox series

diff --git a/src/libcamera/pipeline_handler.cpp b/src/libcamera/pipeline_handler.cpp
index e5f9e55c9783..f398f62e0085 100644
--- a/src/libcamera/pipeline_handler.cpp
+++ b/src/libcamera/pipeline_handler.cpp
@@ -380,7 +380,16 @@  void PipelineHandler::stop(Camera *camera)
 	while (!waitingRequests.empty()) {
 		Request *request = waitingRequests.front();
 		waitingRequests.pop();
-		cancelRequest(request);
+
+		/*
+		 * Cancel all requests by marking them as cancelled and calling
+		 * doQueueRequest() instead of cancelRequest(). This ensures
+		 * that the requests get a sequence number and are temporarily
+		 * added to queuedRequests_ so they can be properly completed in
+		 * completeRequest().
+		 */
+		request->_d()->cancel();
+		doQueueRequest(request);
 	}
 
 	/* Make sure no requests are pending. */