{"id":8985,"url":"https://patchwork.libcamera.org/api/1.1/patches/8985/?format=json","web_url":"https://patchwork.libcamera.org/patch/8985/","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":"<20200724174827.757493-3-niklas.soderlund@ragnatech.se>","date":"2020-07-24T17:48:26","name":"[libcamera-devel,v2,2/3] cam: capture: Cache the EventLoop handler","commit_ref":null,"pull_url":null,"state":"superseded","archived":false,"hash":"ba36dbd12b315580ea401f1436d4471330f42984","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/8985/mbox/","series":[{"id":1141,"url":"https://patchwork.libcamera.org/api/1.1/series/1141/?format=json","web_url":"https://patchwork.libcamera.org/project/libcamera/list/?series=1141","date":"2020-07-24T17:48:24","name":"cam: Add options to make batch testing with cam easier","version":2,"mbox":"https://patchwork.libcamera.org/series/1141/mbox/"}],"comments":"https://patchwork.libcamera.org/api/patches/8985/comments/","check":"pending","checks":"https://patchwork.libcamera.org/api/patches/8985/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 78A0ABD86F\n\tfor <parsemail@patchwork.libcamera.org>;\n\tFri, 24 Jul 2020 17:48:45 +0000 (UTC)","from lancelot.ideasonboard.com (localhost [IPv6:::1])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTP id 4FD8E61236;\n\tFri, 24 Jul 2020 19:48:45 +0200 (CEST)","from bin-mail-out-06.binero.net (bin-mail-out-06.binero.net\n\t[195.74.38.229])\n\tby lancelot.ideasonboard.com (Postfix) with ESMTPS id 7C7536039B\n\tfor <libcamera-devel@lists.libcamera.org>;\n\tFri, 24 Jul 2020 19:48:41 +0200 (CEST)","from bismarck.berto.se (p4fca2eca.dip0.t-ipconnect.de\n\t[79.202.46.202]) by bin-vsp-out-02.atm.binero.net (Halon) with ESMTPA\n\tid e8d1e1c3-cdd5-11ea-8fb8-005056917f90;\n\tFri, 24 Jul 2020 19:48:40 +0200 (CEST)"],"X-Halon-ID":"e8d1e1c3-cdd5-11ea-8fb8-005056917f90","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 19:48:26 +0200","Message-Id":"<20200724174827.757493-3-niklas.soderlund@ragnatech.se>","X-Mailer":"git-send-email 2.27.0","In-Reply-To":"<20200724174827.757493-1-niklas.soderlund@ragnatech.se>","References":"<20200724174827.757493-1-niklas.soderlund@ragnatech.se>","MIME-Version":"1.0","Subject":"[libcamera-devel] [PATCH v2 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>\n---\n src/cam/capture.cpp | 10 ++++++----\n src/cam/capture.h   |  5 +++--\n 2 files changed, 9 insertions(+), 6 deletions(-)","diff":"diff --git a/src/cam/capture.cpp b/src/cam/capture.cpp\nindex 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 }\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 \ndiff --git a/src/cam/capture.h b/src/cam/capture.h\nindex 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","prefixes":["libcamera-devel","v2","2/3"]}