From patchwork Sat Jun 3 07:56:08 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 18691 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 D11AEC32AB for ; Sat, 3 Jun 2023 07:57:18 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 8DB476288E; Sat, 3 Jun 2023 09:57:18 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1685779038; bh=edz4xFWTKtABKI4EC7dWnAxOKJeMyqJxs/BmtaJae4g=; h=To:Date:In-Reply-To:References:Subject:List-Id:List-Unsubscribe: List-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To: From; b=DlInb5l4hNNOD7j7RzKRNvHSB3c3ZDvOFW9KphUZ5kC6wS3JbHebPRZe+JH0IUDQc TZMZ3MK/fuh+mNI7OdKDopT/9z9pzvv102Egtetm2tKDqEEnRkfjoWRhayOBZ1KTHN 4KPktxsJKLOvQOvc4B6MEmDaBkx0LfeacDmXVuIgBcVTOJU1GXkAnRFh3g1f0ZlGJ/ qxCagljVlacTupF904fVERzpFhUv/6AYCNgqla9gii04vPfNu4hOygyLru8a7GPYqR bZj/FTyqfp+hoNFC8KriU6P81SvUHq2MkJ/N9yDYA+uB3W3D14LPNpzSiDepOIMuiN /MstL5n4xGMpg== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 73AB662709 for ; Sat, 3 Jun 2023 09:57:12 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="hlKKD5n/"; dkim-atps=neutral Received: from desky.lan (91-154-35-171.elisa-laajakaista.fi [91.154.35.171]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id DAB6E468; Sat, 3 Jun 2023 09:56:48 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1685779009; bh=edz4xFWTKtABKI4EC7dWnAxOKJeMyqJxs/BmtaJae4g=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=hlKKD5n/2F2WCYX5KuPItkgme2S4CwUNNQ7mpXjOgFWzvgvj7paovpr2UhWqMw9pP cDwmpMc+EfHltmZzgznuHxPv+J3RM19Qm4NYtxWDHz84f2ZTX4EY6E8nTnPgHkNDQE Js/JEur4XQh4iSn779CBhyOADUiEFC+PAANt/GCc= To: libcamera-devel@lists.libcamera.org Date: Sat, 3 Jun 2023 10:56:08 +0300 Message-Id: <20230603075615.20663-7-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230603075615.20663-1-tomi.valkeinen@ideasonboard.com> References: <20230603075615.20663-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v5 06/13] py: simple-capture.py: Use new events support 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: , X-Patchwork-Original-From: Tomi Valkeinen via libcamera-devel From: Tomi Valkeinen Reply-To: Tomi Valkeinen Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Update simple-capture.py to the new event model. Signed-off-by: Tomi Valkeinen Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/py/examples/simple-capture.py | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/src/py/examples/simple-capture.py b/src/py/examples/simple-capture.py index 4b85408f..4fa36d6f 100755 --- a/src/py/examples/simple-capture.py +++ b/src/py/examples/simple-capture.py @@ -107,17 +107,22 @@ def main(): sel.register(cm.event_fd, selectors.EVENT_READ) while frames_done < TOTAL_FRAMES: - # cm.get_ready_requests() does not block, so we use a Selector to wait - # for a camera event. Here we should almost always get a single - # Request, but in some cases there could be multiple or none. + # cm.get_events() does not block, so we use a Selector to wait for a + # camera event. Here we should almost always get a single request + # completion event, but in some cases there could be multiple ones, + # other events, or no events at all. events = sel.select() if not events: continue - reqs = cm.get_ready_requests() + for ev in cm.get_events(): + # We are only interested in RequestCompleted events + if ev.type != libcam.Event.Type.RequestCompleted: + continue + + req = ev.request - for req in reqs: frames_done += 1 buffers = req.buffers