From patchwork Tue Oct 12 02:23:21 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14106 Return-Path: X-Original-To: parsemail@patchwork.libcamera.org Delivered-To: parsemail@patchwork.libcamera.org Received: from lancelot.ideasonboard.com (lancelot.ideasonboard.com [92.243.16.209]) by patchwork.libcamera.org (Postfix) with ESMTPS id 1C1EAC323E for ; Tue, 12 Oct 2021 02:23:44 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id C088D68F5A; Tue, 12 Oct 2021 04:23:42 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fLFHJoS+"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 2C08568F4A for ; Tue, 12 Oct 2021 04:23:40 +0200 (CEST) Received: from pendragon.lan (62-78-145-57.bb.dnainternet.fi [62.78.145.57]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id D43E98C4 for ; Tue, 12 Oct 2021 04:23:39 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1634005420; bh=I23Z9JaXjMWBghec/NOt2m4OrRXgZVnbpe0uWSjU6pY=; h=From:To:Subject:Date:In-Reply-To:References:From; b=fLFHJoS+jKOcOfVYV4XGiOsl6Xzmyg9XCO/hu/X8FOwXPk0jLRDONgsm22f8ThhHr m6aa0Ws3F6szTCxApQYPINMBMwVDMdmhRHdB+Yzxcr8SqFE/pO9/sp9rCrwox3HAlo 6XIwxFJIuHlqiJPbnytYrgj/ALh0trEhCg7HhQW0= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Tue, 12 Oct 2021 05:23:21 +0300 Message-Id: <20211012022321.27034-4-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20211012022321.27034-1-laurent.pinchart@ideasonboard.com> References: <20211012022321.27034-1-laurent.pinchart@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH 3/3] cam: Drop frames once the capture limit is reached X-BeenThere: libcamera-devel@lists.libcamera.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" 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 Reviewed-by: Kieran Bingham --- 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.