[libcamera-devel] [PATCH 3/3] cam: Drop frames once the capture limit is reached

Laurent Pinchart laurent.pinchart at ideasonboard.com
Tue Oct 12 04:23:21 CEST 2021


The camera session keeps requeuing requests until the capture limit is
reached. This causes more request than the limit to complete, as there's
a queue of requests in flight. When capturing from multiple cameras
concurrently, this results in the captureDone signal being emitted for
every request completion after the limit is reached, instead of once per
camera session when reaching the limit.

Fix this by simply dropping any request that completes after the limit
is reached. We could instead avoid requeuing more requests than needed
to reach the limit, but that may cause request starvation in pipelines,
which are currently not handled consistently (or correctly).

Signed-off-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
---
 src/cam/camera_session.cpp | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/src/cam/camera_session.cpp b/src/cam/camera_session.cpp
index 605018278c5a..594cd51bb6a2 100644
--- a/src/cam/camera_session.cpp
+++ b/src/cam/camera_session.cpp
@@ -348,6 +348,9 @@ void CameraSession::processRequest(Request *request)
 {
 	const Request::BufferMap &buffers = request->buffers();
 
+	if (captureLimit_ && captureCount_ >= captureLimit_)
+		return;
+
 	/*
 	 * Compute the frame rate. The timestamp is arbitrarily retrieved from
 	 * the first buffer, as all buffers should have matching timestamps.
-- 
Regards,

Laurent Pinchart



More information about the libcamera-devel mailing list