From patchwork Tue Oct 12 22:00:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Laurent Pinchart X-Patchwork-Id: 14110 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 03274C323E for ; Tue, 12 Oct 2021 22:01:14 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 63A4468F51; Wed, 13 Oct 2021 00:01:13 +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="W76OTpdA"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0EBBA6012B for ; Wed, 13 Oct 2021 00:01:11 +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 061F6CC; Wed, 13 Oct 2021 00:01:09 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1634076070; bh=RQRY7YcE/PghAOykN1xd3xECAu6OFwC3Esosu2CDu8k=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=W76OTpdApzWjpsX7LH+IP8C9MqZsB9jPVSo5SZXJ4ll57HvXRAUpHzVt8IfGmy76H lVtrMCs2gJe+N6WVRGf5tCUoS3wSi1Y2ntC/vgvSEv9NMW6Uuv8bimkufZB66x9Jl8 5uxxBLZj7T+j9F11mbBToPEkxZ5uZARBzg1uKwjU= From: Laurent Pinchart To: libcamera-devel@lists.libcamera.org Date: Wed, 13 Oct 2021 01:00:53 +0300 Message-Id: <20211012220053.5139-1-laurent.pinchart@ideasonboard.com> X-Mailer: git-send-email 2.32.0 In-Reply-To: <163403741592.2943484.12457394596940840718@Monstersaurus> References: <163403741592.2943484.12457394596940840718@Monstersaurus> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v1.1 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 --- Changes since v1: - Add comments --- src/cam/camera_session.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/src/cam/camera_session.cpp b/src/cam/camera_session.cpp index 605018278c5a..1bf460fa3fb7 100644 --- a/src/cam/camera_session.cpp +++ b/src/cam/camera_session.cpp @@ -346,6 +346,16 @@ void CameraSession::requestComplete(Request *request) void CameraSession::processRequest(Request *request) { + /* + * If we've reached the capture limit, we're done. This doesn't + * duplicate the check below that emits the captureDone signal, as this + * function will be called for each request still in flight after the + * capture limit is reached and we don't want to emit the signal every + * single time. + */ + if (captureLimit_ && captureCount_ >= captureLimit_) + return; + const Request::BufferMap &buffers = request->buffers(); /* @@ -398,6 +408,10 @@ void CameraSession::processRequest(Request *request) } } + /* + * Notify the user that capture is complete if the limit has just been + * reached. + */ captureCount_++; if (captureLimit_ && captureCount_ >= captureLimit_) { captureDone.emit();