[{"id":27240,"web_url":"https://patchwork.libcamera.org/comment/27240/","msgid":"<20230605051642.GE22604@pendragon.ideasonboard.com>","date":"2023-06-05T05:16:42","subject":"Re: [libcamera-devel] [PATCH v5 08/13] py: simple-cam.py: Use new\n\tevents support","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Tomi,\n\nThank you for the patch.\n\nOn Sat, Jun 03, 2023 at 10:56:10AM +0300, Tomi Valkeinen wrote:\n> Update simple-cam.py to the new event model.\n> \n> Signed-off-by: Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>\n> Reviewed-by: Jacopo Mondi <jacopo@jmondi.org>\n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> ---\n>  src/py/examples/simple-cam.py | 19 ++++++++++---------\n>  1 file changed, 10 insertions(+), 9 deletions(-)\n> \n> diff --git a/src/py/examples/simple-cam.py b/src/py/examples/simple-cam.py\n> index 1cd1019d..2d359cb7 100755\n> --- a/src/py/examples/simple-cam.py\n> +++ b/src/py/examples/simple-cam.py\n> @@ -19,16 +19,17 @@ TIMEOUT_SEC = 3\n>  \n>  \n>  def handle_camera_event(cm):\n> -    # cm.get_ready_requests() returns the ready requests, which in our case\n> -    # should almost always return a single Request, but in some cases there\n> -    # could be multiple or none.\n> +    # cm.get_events() returns the ready events, which in our case should\n> +    # almost always be a single RequestCompleted event, but in some cases\n> +    # there could be multiple ones, other events, or no events at all.\n\nSame comment as for 06/13.\n\n>  \n> -    reqs = cm.get_ready_requests()\n> +    for ev in cm.get_events():\n> +        # We are only interested in RequestCompleted events\n> +        if ev.type != libcam.Event.Type.RequestCompleted:\n> +            continue\n>  \n> -    # Process the captured frames\n> -\n> -    for req in reqs:\n> -        process_request(req)\n> +        # Process the captured frames\n> +        process_request(ev.request)\n>  \n>  \n>  def process_request(request):\n> @@ -304,7 +305,7 @@ def main():\n>      # CameraManager and an event will be raised using eventfd.\n>      #\n>      # The list of completed Requests can be retrieved with\n> -    # CameraManager.get_ready_requests(), which will also clear the list in the\n> +    # CameraManager.get_events(), which will also clear the list in the\n>      # CameraManager.\n>      #\n>      # The eventfd can be retrieved from CameraManager.event_fd, and the fd can","headers":{"Return-Path":"<libcamera-devel-bounces@lists.libcamera.org>","X-Original-To":"parsemail@patchwork.libcamera.org","Delivered-To":"parsemail@patchwork.libcamera.org","Received":["from lancelot.ideasonboard.com (lancelot.ideasonboard.com\n\t[92.243.16.209])\n\tby patchwork.libcamera.org (Postfix) with ESMTPS id 52979C3200\n\tfor <parsemail@patchwork.libcamera.org>;\n\tMon,  5 Jun 2023 05:16:46 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 0BF5B6287D;\n\tMon,  5 Jun 2023 07:16:46 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7219362722\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tMon,  5 Jun 2023 07:16:44 +0200 (CEST)","from pendragon.ideasonboard.com (om126156242094.26.openmobile.ne.jp\n\t[126.156.242.94])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id 639001BA;\n\tMon,  5 Jun 2023 07:16:18 +0200 (CEST)"],"DKIM-Signature":["v=1; a=rsa-sha256; c=relaxed/simple; d=libcamera.org;\n\ts=mail; t=1685942206;\n\tbh=Jw3NSmgDjRm5fN0XHzHaTv6f7yONIE1DavVp0FZx21Y=;\n\th=Date:To:References:In-Reply-To:Subject:List-Id:List-Unsubscribe:\n\tList-Archive:List-Post:List-Help:List-Subscribe:From:Reply-To:Cc:\n\tFrom;\n\tb=zoQgTBtDk72Tp4g4NUzFB3e79WBRUCqEgWe13ULQSqxk4LV+b9xsxQEBAXWayTIVG\n\tkqfCkIdXxI0WiXSTRg7esg/K1WLcukh7ak5zpz8FDJHu83Sp8VWuqdjaTIbJ/erUHa\n\twAeAqo7QhXz05LTIItZHiyPlnkLPcVODGBp+vSMMelNADOTOQma0uTHmylyhj34Hoe\n\tdXQPIisQYZQuaSttOBVu6G5wucXftTxvqmht/YHfIqhL3w4GWz4BLG+aYVKtfdb0IY\n\tKeaYnlwqG1rNPHD2H1qk2ivJti8gzuJKgNtq5yM/Ysp2QINZW+QmH4uWeEAsLElmJW\n\t8csqJEGdiv8Bw==","v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1685942180;\n\tbh=Jw3NSmgDjRm5fN0XHzHaTv6f7yONIE1DavVp0FZx21Y=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=pBZFcYPYU/9he8Ekf5E2SHOiTi1lnHxdEr2y6GFSO2kHVHJGEGpmeGTYR8G7CNrgV\n\ttH+uJcrsL7Iy7f/qkuogAUgN9WR3Nm0/TzHqvqgtq2Yd30SxKmlDHEpRMm/P8MpUMF\n\tstd8HowIqPFK2bsSHvOgRPKF5sj3ZqcqhOc0Hfmw="],"Authentication-Results":"lancelot.ideasonboard.com; dkim=pass (1024-bit key; \n\tunprotected) header.d=ideasonboard.com\n\theader.i=@ideasonboard.com\n\theader.b=\"pBZFcYPY\"; dkim-atps=neutral","Date":"Mon, 5 Jun 2023 08:16:42 +0300","To":"Tomi Valkeinen <tomi.valkeinen@ideasonboard.com>","Message-ID":"<20230605051642.GE22604@pendragon.ideasonboard.com>","References":"<20230603075615.20663-1-tomi.valkeinen@ideasonboard.com>\n\t<20230603075615.20663-9-tomi.valkeinen@ideasonboard.com>","MIME-Version":"1.0","Content-Type":"text/plain; charset=utf-8","Content-Disposition":"inline","In-Reply-To":"<20230603075615.20663-9-tomi.valkeinen@ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v5 08/13] py: simple-cam.py: Use new\n\tevents support","X-BeenThere":"libcamera-devel@lists.libcamera.org","X-Mailman-Version":"2.1.29","Precedence":"list","List-Id":"<libcamera-devel.lists.libcamera.org>","List-Unsubscribe":"<https://lists.libcamera.org/options/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=unsubscribe>","List-Archive":"<https://lists.libcamera.org/pipermail/libcamera-devel/>","List-Post":"<mailto:libcamera-devel@lists.libcamera.org>","List-Help":"<mailto:libcamera-devel-request@lists.libcamera.org?subject=help>","List-Subscribe":"<https://lists.libcamera.org/listinfo/libcamera-devel>,\n\t<mailto:libcamera-devel-request@lists.libcamera.org?subject=subscribe>","From":"Laurent Pinchart via libcamera-devel\n\t<libcamera-devel@lists.libcamera.org>","Reply-To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Cc":"libcamera-devel@lists.libcamera.org","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]