From patchwork Thu Mar 9 14:25:53 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tomi Valkeinen X-Patchwork-Id: 18368 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 8354CC329F for ; Thu, 9 Mar 2023 14:26:26 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id BFE5162702; Thu, 9 Mar 2023 15:26:25 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org; s=mail; t=1678371985; bh=iaRylJ5l1sFUWopCwUojy8cIUA0Y2r4I2IXZHJH+WuA=; 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=Q+xrVVB+f+mJBQsCXg15oIwozh7qPMgrtfvx+AmrFrmmfTTUxWMq0Xl5TuWFto1qc PwGBgf521obcrKK1rcBYM9C+IJQXuVfWxBrh082YUqPxnORmEXCOYiS/EUYZ1vbKax M1KEv5CkJL4n+PorWTP2teqBnhzqm6tuDxoTRdTkxiPcZpTOt3QM2I4w2EGrOMv24+ 5BsQB9InlGgav0xT6XWsFnynFRvgBNuAkALuq+RK3HF0fMhCHwxrUAaRYOHGnntrrY F2QrNuVirXqHcp/vGOc2KqC7FiwhmJyQd16y/L2cQC3tyIFfP27eT+Ff3MD3CouLCa rSyiSVAwEUhUw== Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 4D24D626E6 for ; Thu, 9 Mar 2023 15:26:19 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="cRcvIR9w"; dkim-atps=neutral Received: from desky.lan (91-154-32-225.elisa-laajakaista.fi [91.154.32.225]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id BEC66886; Thu, 9 Mar 2023 15:26:18 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1678371979; bh=iaRylJ5l1sFUWopCwUojy8cIUA0Y2r4I2IXZHJH+WuA=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=cRcvIR9wgXxifvOH+cisvmqvf37JwsNTjSZp5ySpudmjsxX2A6TYjOCeQsWEmdgVs DVwMieZLUYnn64QMSIkQZ8ErpzukFycou1NVyXDLELZhTJIRniLdKmMmA7WoOnFEcp 31yie2niS0tC4YcD6jruQyQdzy4aHsms+WYh6lVo= To: libcamera-devel@lists.libcamera.org Date: Thu, 9 Mar 2023 16:25:53 +0200 Message-Id: <20230309142601.70556-8-tomi.valkeinen@ideasonboard.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230309142601.70556-1-tomi.valkeinen@ideasonboard.com> References: <20230309142601.70556-1-tomi.valkeinen@ideasonboard.com> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v4 07/15] py: simple-cam.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-cam.py to the new event model. Signed-off-by: Tomi Valkeinen Reviewed-by: Jacopo Mondi Reviewed-by: Laurent Pinchart --- src/py/examples/simple-cam.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/src/py/examples/simple-cam.py b/src/py/examples/simple-cam.py index 1cd1019d..2d359cb7 100755 --- a/src/py/examples/simple-cam.py +++ b/src/py/examples/simple-cam.py @@ -19,16 +19,17 @@ TIMEOUT_SEC = 3 def handle_camera_event(cm): - # cm.get_ready_requests() returns the ready requests, which in our case - # should almost always return a single Request, but in some cases there - # could be multiple or none. + # cm.get_events() returns the ready events, which in our case should + # almost always be a single RequestCompleted event, but in some cases + # there could be multiple ones, other events, or no events at all. - 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 - # Process the captured frames - - for req in reqs: - process_request(req) + # Process the captured frames + process_request(ev.request) def process_request(request): @@ -304,7 +305,7 @@ def main(): # CameraManager and an event will be raised using eventfd. # # The list of completed Requests can be retrieved with - # CameraManager.get_ready_requests(), which will also clear the list in the + # CameraManager.get_events(), which will also clear the list in the # CameraManager. # # The eventfd can be retrieved from CameraManager.event_fd, and the fd can