[{"id":11583,"web_url":"https://patchwork.libcamera.org/comment/11583/","msgid":"<20200724175750.GY5921@pendragon.ideasonboard.com>","date":"2020-07-24T17:57:50","subject":"Re: [libcamera-devel] [PATCH v2 2/3] cam: capture: Cache the\n\tEventLoop handler","submitter":{"id":2,"url":"https://patchwork.libcamera.org/api/people/2/","name":"Laurent Pinchart","email":"laurent.pinchart@ideasonboard.com"},"content":"Hi Niklas,\n\nThank you for the patch.\n\nOn Fri, Jul 24, 2020 at 07:48:26PM +0200, Niklas Söderlund wrote:\n> Prepare for the ability to exit the event loop based on conditions in\n> the request complete handler by caching the pointer instead of passing\n> it as an argument.\n> \n> Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> ---\n>  src/cam/capture.cpp | 10 ++++++----\n>  src/cam/capture.h   |  5 +++--\n>  2 files changed, 9 insertions(+), 6 deletions(-)\n> \n> diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp\n> index 55fa2dabcee97f21..aa53c407d7b71b44 100644\n> --- a/src/cam/capture.cpp\n> +++ b/src/cam/capture.cpp\n> @@ -17,7 +17,7 @@\n>  using namespace libcamera;\n>  \n>  Capture::Capture(std::shared_ptr<Camera> camera, CameraConfiguration *config)\n> -\t: camera_(camera), config_(config), writer_(nullptr)\n> +\t: camera_(camera), config_(config), writer_(nullptr), loop_(nullptr)\n\nWould it make sense to pass the event loop to the constructor ?\n\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n\n>  {\n>  }\n>  \n> @@ -25,6 +25,8 @@ int Capture::run(EventLoop *loop, const OptionsParser::Options &options)\n>  {\n>  \tint ret;\n>  \n> +\tloop_ = loop;\n> +\n>  \tif (!camera_) {\n>  \t\tstd::cout << \"Can't capture without a camera\" << std::endl;\n>  \t\treturn -ENODEV;\n> @@ -54,7 +56,7 @@ int Capture::run(EventLoop *loop, const OptionsParser::Options &options)\n>  \n>  \tFrameBufferAllocator *allocator = new FrameBufferAllocator(camera_);\n>  \n> -\tret = capture(loop, allocator);\n> +\tret = capture(allocator);\n>  \n>  \tif (options.isSet(OptFile)) {\n>  \t\tdelete writer_;\n> @@ -66,7 +68,7 @@ int Capture::run(EventLoop *loop, const OptionsParser::Options &options)\n>  \treturn ret;\n>  }\n>  \n> -int Capture::capture(EventLoop *loop, FrameBufferAllocator *allocator)\n> +int Capture::capture(FrameBufferAllocator *allocator)\n>  {\n>  \tint ret;\n>  \n> @@ -132,7 +134,7 @@ int Capture::capture(EventLoop *loop, FrameBufferAllocator *allocator)\n>  \t}\n>  \n>  \tstd::cout << \"Capture until user interrupts by SIGINT\" << std::endl;\n> -\tret = loop->exec();\n> +\tret = loop_->exec();\n>  \tif (ret)\n>  \t\tstd::cout << \"Failed to run capture loop\" << std::endl;\n>  \n> diff --git a/src/cam/capture.h b/src/cam/capture.h\n> index 9bca5661070efcf5..67c6260bfe24aefc 100644\n> --- a/src/cam/capture.h\n> +++ b/src/cam/capture.h\n> @@ -28,8 +28,7 @@ public:\n>  \n>  \tint run(EventLoop *loop, const OptionsParser::Options &options);\n>  private:\n> -\tint capture(EventLoop *loop,\n> -\t\t    libcamera::FrameBufferAllocator *allocator);\n> +\tint capture(libcamera::FrameBufferAllocator *allocator);\n>  \n>  \tvoid requestComplete(libcamera::Request *request);\n>  \n> @@ -39,6 +38,8 @@ private:\n>  \tstd::map<libcamera::Stream *, std::string> streamName_;\n>  \tBufferWriter *writer_;\n>  \tstd::chrono::steady_clock::time_point last_;\n> +\n> +\tEventLoop *loop_;\n>  };\n>  \n>  #endif /* __CAM_CAPTURE_H__ */","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 28AD6BD878\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Jul 2020 17:57:58 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id E8A1F6121D;\n\tFri, 24 Jul 2020 19:57:57 +0200 (CEST)","from perceval.ideasonboard.com (perceval.ideasonboard.com\n\t[213.167.242.64])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 3D8136039B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Jul 2020 19:57:57 +0200 (CEST)","from pendragon.ideasonboard.com (81-175-216-236.bb.dnainternet.fi\n\t[81.175.216.236])\n\tby perceval.ideasonboard.com (Postfix) with ESMTPSA id C6EAA538;\n\tFri, 24 Jul 2020 19:57:56 +0200 (CEST)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (1024-bit key;\n\tunprotected) header.d=ideasonboard.com header.i=@ideasonboard.com\n\theader.b=\"mdFMwS7b\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com;\n\ts=mail; t=1595613477;\n\tbh=s5LDikXiIjcFErpOqU75CNvgHsVQ6p+8WOpTEvXHeaU=;\n\th=Date:From:To:Cc:Subject:References:In-Reply-To:From;\n\tb=mdFMwS7bbZIddmtVNIopCcwOwmsiGrivRLa9v4pjkirh7fB/5oaHzl75z2mpRZpOm\n\tg4iG2ThL9pOgQ3QE/9llhopjjqNSUElVKRMnoWL0mnknkYfgDkDkuDt+Wp1wLD8wex\n\tZGqc9rMlc5eaZUFwkSoXZhEFE1UKJaFiMxeHFCAM=","Date":"Fri, 24 Jul 2020 20:57:50 +0300","From":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","To":"Niklas =?utf-8?q?S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","Message-ID":"<20200724175750.GY5921@pendragon.ideasonboard.com>","References":"<20200724174827.757493-1-niklas.soderlund@ragnatech.se>\n\t<20200724174827.757493-3-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200724174827.757493-3-niklas.soderlund@ragnatech.se>","Subject":"Re: [libcamera-devel] [PATCH v2 2/3] cam: capture: Cache the\n\tEventLoop handler","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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"utf-8\"","Content-Transfer-Encoding":"base64","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}},{"id":11586,"web_url":"https://patchwork.libcamera.org/comment/11586/","msgid":"<20200724191003.GC2729799@oden.dyn.berto.se>","date":"2020-07-24T19:10:03","subject":"Re: [libcamera-devel] [PATCH v2 2/3] cam: capture: Cache the\n\tEventLoop handler","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/people/5/","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"content":"Hi Laurent,\n\nThanks for your feedback.\n\nOn 2020-07-24 20:57:50 +0300, Laurent Pinchart wrote:\n> Hi Niklas,\n> \n> Thank you for the patch.\n> \n> On Fri, Jul 24, 2020 at 07:48:26PM +0200, Niklas Söderlund wrote:\n> > Prepare for the ability to exit the event loop based on conditions in\n> > the request complete handler by caching the pointer instead of passing\n> > it as an argument.\n> > \n> > Signed-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\n> > Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\n> > ---\n> >  src/cam/capture.cpp | 10 ++++++----\n> >  src/cam/capture.h   |  5 +++--\n> >  2 files changed, 9 insertions(+), 6 deletions(-)\n> > \n> > diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp\n> > index 55fa2dabcee97f21..aa53c407d7b71b44 100644\n> > --- a/src/cam/capture.cpp\n> > +++ b/src/cam/capture.cpp\n> > @@ -17,7 +17,7 @@\n> >  using namespace libcamera;\n> >  \n> >  Capture::Capture(std::shared_ptr<Camera> camera, CameraConfiguration *config)\n> > -\t: camera_(camera), config_(config), writer_(nullptr)\n> > +\t: camera_(camera), config_(config), writer_(nullptr), loop_(nullptr)\n> \n> Would it make sense to pass the event loop to the constructor ?\n\nThat might be nicer, will do so in v3.\n\n> \n> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n> \n> >  {\n> >  }\n> >  \n> > @@ -25,6 +25,8 @@ int Capture::run(EventLoop *loop, const OptionsParser::Options &options)\n> >  {\n> >  \tint ret;\n> >  \n> > +\tloop_ = loop;\n> > +\n> >  \tif (!camera_) {\n> >  \t\tstd::cout << \"Can't capture without a camera\" << std::endl;\n> >  \t\treturn -ENODEV;\n> > @@ -54,7 +56,7 @@ int Capture::run(EventLoop *loop, const OptionsParser::Options &options)\n> >  \n> >  \tFrameBufferAllocator *allocator = new FrameBufferAllocator(camera_);\n> >  \n> > -\tret = capture(loop, allocator);\n> > +\tret = capture(allocator);\n> >  \n> >  \tif (options.isSet(OptFile)) {\n> >  \t\tdelete writer_;\n> > @@ -66,7 +68,7 @@ int Capture::run(EventLoop *loop, const OptionsParser::Options &options)\n> >  \treturn ret;\n> >  }\n> >  \n> > -int Capture::capture(EventLoop *loop, FrameBufferAllocator *allocator)\n> > +int Capture::capture(FrameBufferAllocator *allocator)\n> >  {\n> >  \tint ret;\n> >  \n> > @@ -132,7 +134,7 @@ int Capture::capture(EventLoop *loop, FrameBufferAllocator *allocator)\n> >  \t}\n> >  \n> >  \tstd::cout << \"Capture until user interrupts by SIGINT\" << std::endl;\n> > -\tret = loop->exec();\n> > +\tret = loop_->exec();\n> >  \tif (ret)\n> >  \t\tstd::cout << \"Failed to run capture loop\" << std::endl;\n> >  \n> > diff --git a/src/cam/capture.h b/src/cam/capture.h\n> > index 9bca5661070efcf5..67c6260bfe24aefc 100644\n> > --- a/src/cam/capture.h\n> > +++ b/src/cam/capture.h\n> > @@ -28,8 +28,7 @@ public:\n> >  \n> >  \tint run(EventLoop *loop, const OptionsParser::Options &options);\n> >  private:\n> > -\tint capture(EventLoop *loop,\n> > -\t\t    libcamera::FrameBufferAllocator *allocator);\n> > +\tint capture(libcamera::FrameBufferAllocator *allocator);\n> >  \n> >  \tvoid requestComplete(libcamera::Request *request);\n> >  \n> > @@ -39,6 +38,8 @@ private:\n> >  \tstd::map<libcamera::Stream *, std::string> streamName_;\n> >  \tBufferWriter *writer_;\n> >  \tstd::chrono::steady_clock::time_point last_;\n> > +\n> > +\tEventLoop *loop_;\n> >  };\n> >  \n> >  #endif /* __CAM_CAPTURE_H__ */\n> \n> -- \n> Regards,\n> \n> Laurent Pinchart","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 F2AE6BD86F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Jul 2020 19:10:07 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 60EAB6121D;\n\tFri, 24 Jul 2020 21:10:07 +0200 (CEST)","from mail-lf1-x141.google.com (mail-lf1-x141.google.com\n\t[IPv6:2a00:1450:4864:20::141])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id EB4726039B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Jul 2020 21:10:05 +0200 (CEST)","by mail-lf1-x141.google.com with SMTP id i19so5742982lfj.8\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Jul 2020 12:10:05 -0700 (PDT)","from localhost (h-209-203.A463.priv.bahnhof.se. [155.4.209.203])\n\tby smtp.gmail.com with ESMTPSA id\n\tt10sm430810ljg.60.2020.07.24.12.10.04\n\t(version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256);\n\tFri, 24 Jul 2020 12:10:04 -0700 (PDT)"],"Authentication-Results":"lancelot.ideasonboard.com;\n\tdkim=fail reason=\"signature verification failed\" (2048-bit key;\n\tunprotected) header.d=ragnatech-se.20150623.gappssmtp.com\n\theader.i=@ragnatech-se.20150623.gappssmtp.com\n\theader.b=\"ibtF7AgX\"; dkim-atps=neutral","DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=ragnatech-se.20150623.gappssmtp.com; s=20150623;\n\th=date:from:to:cc:subject:message-id:references:mime-version\n\t:content-disposition:content-transfer-encoding:in-reply-to;\n\tbh=ZyODXZRrx63NT4QLNJ6mXPCyPWCAo932Wmcw+8cSrEQ=;\n\tb=ibtF7AgXVMVNM4VbJhJ3G1GODhQJIHfKr6DM29a1rCRbllJOsj67YkvCnOXi+eVHbn\n\tvqy4Ib3i1pw0+aEoN1MBLCPntgchVwvEBDV1a1/2PyRllOSveMREEALZUv992FZAvRva\n\t31cqIT7LAgdtLahALBNtsE9QSHK7FCJoVO8bSaV0D067lpZkAPgEi2yWeesTQ1+pfe6o\n\tZ1hK3h4m2HrPlM8ysxACfgkksb8qyRzbKT63U995cpk9POFzueD/irWFMYOENErZw8bX\n\t0487swo2C6+VjHWavaH/vLCLhYSv3u0eIcdCVYzixiv4fJHvI0hCpMpHH0Uy7+Zz7qq2\n\t4wyQ==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:date:from:to:cc:subject:message-id:references\n\t:mime-version:content-disposition:content-transfer-encoding\n\t:in-reply-to;\n\tbh=ZyODXZRrx63NT4QLNJ6mXPCyPWCAo932Wmcw+8cSrEQ=;\n\tb=rNRJcLZK6mS/rXXwKpUwJ47yf+dj4E6vJCnEU58mLAEn9aDDVGs0PWpTUDITXjiKyo\n\tob7V40jLrjImMxRef+LNH8mPBauS72IkqLAoZoE6JQFyVCfDGs51BMiMz2QjzNCn9Q2t\n\thT7kbJ4CR3FsjeQsVN+0VsSPKKnjwCdP8QQjx6ay+WfC+UFM9jY9+Y0yyCCXst8dWX1P\n\t3qfivgb0ktX9tvbN4xsUfguOakpXGR4KZdOygEgL9qbIEw69QRok0IsuyXsG6BERP3hk\n\t8H2JiTX3O9l8qVcPIDkHmxHZIg0jFms8Oix6XXsJQDpccHiYBwriw62a7tRAQw6rffix\n\tfjfg==","X-Gm-Message-State":"AOAM531AQO/r4JbKD7Lu71DfikAk0fi9tJjhJVcQ81xe9Go8jDupWUJN\n\t9oNQxM5oGd0kHiRZm2N2TDmCOJT+Z4A=","X-Google-Smtp-Source":"ABdhPJxDXZ9ocKjf8yQoLJQ7qvoOQls+AajyLbx8JQ3T69hC3/o0d7CSLdvB9vRBhUQvtd2URsiAGg==","X-Received":"by 2002:a19:e45:: with SMTP id 66mr5777993lfo.82.1595617805280; \n\tFri, 24 Jul 2020 12:10:05 -0700 (PDT)","Date":"Fri, 24 Jul 2020 21:10:03 +0200","From":"Niklas =?iso-8859-1?q?S=F6derlund?= <niklas.soderlund@ragnatech.se>","To":"Laurent Pinchart <laurent.pinchart@ideasonboard.com>","Message-ID":"<20200724191003.GC2729799@oden.dyn.berto.se>","References":"<20200724174827.757493-1-niklas.soderlund@ragnatech.se>\n\t<20200724174827.757493-3-niklas.soderlund@ragnatech.se>\n\t<20200724175750.GY5921@pendragon.ideasonboard.com>","MIME-Version":"1.0","Content-Disposition":"inline","In-Reply-To":"<20200724175750.GY5921@pendragon.ideasonboard.com>","Subject":"Re: [libcamera-devel] [PATCH v2 2/3] cam: capture: Cache the\n\tEventLoop handler","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>","Cc":"libcamera-devel@lists.libcamera.org","Content-Type":"text/plain; charset=\"iso-8859-1\"","Content-Transfer-Encoding":"quoted-printable","Errors-To":"libcamera-devel-bounces@lists.libcamera.org","Sender":"\"libcamera-devel\" <libcamera-devel-bounces@lists.libcamera.org>"}}]