{"id":8989,"url":"https://patchwork.libcamera.org/api/1.1/patches/8989/?format=json","web_url":"https://patchwork.libcamera.org/patch/8989/","project":{"id":1,"url":"https://patchwork.libcamera.org/api/1.1/projects/1/?format=json","name":"libcamera","link_name":"libcamera","list_id":"libcamera_core","list_email":"libcamera-devel@lists.libcamera.org","web_url":"","scm_url":"","webscm_url":""},"msgid":"<20200724191851.803350-3-niklas.soderlund@ragnatech.se>","date":"2020-07-24T19:18:50","name":"[libcamera-devel,v3,2/3] cam: capture: Cache the EventLoop handler","commit_ref":"ed734693350220f38aab768aee5e106b92dc9eb9","pull_url":null,"state":"accepted","archived":false,"hash":"38f39b0c82e44fa78751d8c7949cd660bd078b95","submitter":{"id":5,"url":"https://patchwork.libcamera.org/api/1.1/people/5/?format=json","name":"Niklas Söderlund","email":"niklas.soderlund@ragnatech.se"},"delegate":null,"mbox":"https://patchwork.libcamera.org/patch/8989/mbox/","series":[{"id":1142,"url":"https://patchwork.libcamera.org/api/1.1/series/1142/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1142","date":"2020-07-24T19:18:48","name":"cam: Add options to make batch testing with cam easier","version":3,"mbox":"https://patchwork.libcamera.org/series/1142/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/8989/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/8989/checks/","tags":{},"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 2A6F9BD86F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Jul 2020 19:19:22 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 04AC36124B;\n\tFri, 24 Jul 2020 21:19:22 +0200 (CEST)","from bin-mail-out-05.binero.net (bin-mail-out-05.binero.net\n\t[195.74.38.228])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id C95E961212\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Jul 2020 21:19:17 +0200 (CEST)","from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de\n\t[79.202.46.202]) by bin-vsp-out-03.atm.binero.net (Halon) with ESMTPA\n\tid 67743bf7-cde2-11ea-86ee-0050569116f7;\n\tFri, 24 Jul 2020 21:18:07 +0200 (CEST)"],"X-Halon-ID":"67743bf7-cde2-11ea-86ee-0050569116f7","Authorized-sender":"niklas@soderlund.pp.se","From":"=?utf-8?q?Niklas_S=C3=B6derlund?= <niklas.soderlund@ragnatech.se>","To":"libcamera-devel@lists.libcamera.org","Date":"Fri, 24 Jul 2020 21:18:50 +0200","Message-Id":"<20200724191851.803350-3-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20200724191851.803350-1-niklas.soderlund@ragnatech.se>","References":"<20200724191851.803350-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v3 2/3] cam: capture: Cache the EventLoop\n\thandler","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>","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>"},"content":"Prepare for the ability to exit the event loop based on conditions in\nthe request complete handler by caching the pointer instead of passing\nit as an argument.\n\nSigned-off-by: Niklas Söderlund <niklas.soderlund@ragnatech.se>\nReviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com>\nReviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>\n---\n* Changes since v2\n- Pass EventLoop to constructor instead of run()\n---\n src/cam/capture.cpp | 13 +++++++------\n src/cam/capture.h   | 10 ++++++----\n src/cam/main.cpp    |  4 ++--\n 3 files changed, 15 insertions(+), 12 deletions(-)","diff":"diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp\nindex 55fa2dabcee97f21..f811a18c579508a1 100644\n--- a/src/cam/capture.cpp\n+++ b/src/cam/capture.cpp\n@@ -16,12 +16,13 @@\n \n using namespace libcamera;\n \n-Capture::Capture(std::shared_ptr<Camera> camera, CameraConfiguration *config)\n-\t: camera_(camera), config_(config), writer_(nullptr)\n+Capture::Capture(std::shared_ptr<Camera> camera, CameraConfiguration *config,\n+\t\t EventLoop *loop)\n+\t: camera_(camera), config_(config), writer_(nullptr), loop_(loop)\n {\n }\n \n-int Capture::run(EventLoop *loop, const OptionsParser::Options &options)\n+int Capture::run(const OptionsParser::Options &options)\n {\n \tint ret;\n \n@@ -54,7 +55,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 +67,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 +133,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 \ndiff --git a/src/cam/capture.h b/src/cam/capture.h\nindex 9bca5661070efcf5..acdefc47b24314d2 100644\n--- a/src/cam/capture.h\n+++ b/src/cam/capture.h\n@@ -24,12 +24,12 @@ class Capture\n {\n public:\n \tCapture(std::shared_ptr<libcamera::Camera> camera,\n-\t\tlibcamera::CameraConfiguration *config);\n+\t\tlibcamera::CameraConfiguration *config,\n+\t\tEventLoop *loop);\n \n-\tint run(EventLoop *loop, const OptionsParser::Options &options);\n+\tint run(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 +39,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__ */\ndiff --git a/src/cam/main.cpp b/src/cam/main.cpp\nindex ead0abe3e2abf42d..3e83feabe64e036c 100644\n--- a/src/cam/main.cpp\n+++ b/src/cam/main.cpp\n@@ -341,8 +341,8 @@ int CamApp::run()\n \t}\n \n \tif (options_.isSet(OptCapture)) {\n-\t\tCapture capture(camera_, config_.get());\n-\t\treturn capture.run(loop_, options_);\n+\t\tCapture capture(camera_, config_.get(), loop_);\n+\t\treturn capture.run(options_);\n \t}\n \n \treturn 0;\n","prefixes":["libcamera-devel","v3","2/3"]}