From patchwork Thu Jan 30 11:51:46 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= X-Patchwork-Id: 22679 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 316E8BD808 for ; Thu, 30 Jan 2025 11:51:52 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id DE3BF6858A; Thu, 30 Jan 2025 12:51:51 +0100 (CET) Authentication-Results: lancelot.ideasonboard.com; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=protonmail.com header.i=@protonmail.com header.b="WbYefwHS"; dkim-atps=neutral Received: from mail-10629.protonmail.ch (mail-10629.protonmail.ch [79.135.106.29]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id F216968588 for ; Thu, 30 Jan 2025 12:51:49 +0100 (CET) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=protonmail.com; s=protonmail3; t=1738237909; x=1738497109; bh=44uTnHhpmqWaFRo7925aVDpsEg8M002arxNUFiLyCvI=; h=Date:To:From:Subject:Message-ID:In-Reply-To:References: Feedback-ID:From:To:Cc:Date:Subject:Reply-To:Feedback-ID: Message-ID:BIMI-Selector:List-Unsubscribe:List-Unsubscribe-Post; b=WbYefwHS1iN85kUeUVfNxGINy+z12gEOu1xUCTli5/CDeDYotrmB20TZK6TYi6M5V 32D34FvxO98qOr9yxyZGaTD+kCTXKGhvkhALQA/iYYHpgtwEUjY097C1M6MXoAcu1e wP+bOhlh0k7envL8QyIHOx+bRUzHa+DbV6JaONike4ONr67Pz9oDAKKvXy+tkZBy3n Sio9HTMhgYztJiJQH+eloAY5UaAMMmqyikaaZbW0R/Y5EFsSrQgx9UahTOyyRaDx6f R/wINsyvmDHkfe4uNM/YyLFIdyD9FWpzWzgkxraE4ObeM5W7uXhU+O64q9Qe00XBR/ kLsqCY7M5M9AA== Date: Thu, 30 Jan 2025 11:51:46 +0000 To: libcamera-devel@lists.libcamera.org From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= Subject: [RFC PATCH v3 20/21] apps: lc-compliance: Make `EventLoop` a member Message-ID: <20250130115001.1129305-21-pobrn@protonmail.com> In-Reply-To: <20250130115001.1129305-1-pobrn@protonmail.com> References: <20250130115001.1129305-1-pobrn@protonmail.com> Feedback-ID: 20568564:user:proton X-Pm-Message-ID: c75102745a46ba28d74340cc42d24cd31efd7f87 MIME-Version: 1.0 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: , Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Instead of creating an `EventLoop` in each `run()` invocation and setting a member pointer to the on-stack object, simply make it a member variable. Signed-off-by: Barnabás Pőcze Reviewed-by: Jacopo Mondi --- src/apps/lc-compliance/helpers/capture.cpp | 11 ++++------- src/apps/lc-compliance/helpers/capture.h | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/src/apps/lc-compliance/helpers/capture.cpp b/src/apps/lc-compliance/helpers/capture.cpp index 5032470d9..13a5e3f33 100644 --- a/src/apps/lc-compliance/helpers/capture.cpp +++ b/src/apps/lc-compliance/helpers/capture.cpp @@ -69,16 +69,13 @@ void Capture::run(unsigned int captureLimit, std::optional queueLi captureCount_ = queueCount_ = 0; - EventLoop loop; - loop_ = &loop; - start(); prepareRequests(); for (const auto &request : requests_) queueRequest(request.get()); - EXPECT_EQ(loop_->exec(), 0); + EXPECT_EQ(loop_.exec(), 0); stop(); @@ -140,7 +137,7 @@ void Capture::requestComplete(Request *request) { captureCount_++; if (captureCount_ >= captureLimit_) { - loop_->exit(0); + loop_.exit(0); return; } @@ -170,7 +167,7 @@ void Capture::start() camera_->requestCompleted.connect(this, [this](libcamera::Request *request) { /* Runs in the CameraManager thread. */ - loop_->callLater([this, request] { + loop_.callLater([this, request] { /* Run handler in the context of the event loop. */ requestComplete(request); }, reinterpret_cast(this)); @@ -190,7 +187,7 @@ void Capture::stop() requests_.clear(); - loop_->cancelLater(reinterpret_cast(this)); + loop_.cancelLater(reinterpret_cast(this)); for (const auto &cfg : *config_) { int ret = allocator_.free(cfg.stream()); diff --git a/src/apps/lc-compliance/helpers/capture.h b/src/apps/lc-compliance/helpers/capture.h index dacce1fe2..50dc37c28 100644 --- a/src/apps/lc-compliance/helpers/capture.h +++ b/src/apps/lc-compliance/helpers/capture.h @@ -38,7 +38,7 @@ private: std::unique_ptr config_; std::vector> requests_; - EventLoop *loop_ = nullptr; + EventLoop loop_; unsigned int captureLimit_ = 0; std::optional queueLimit_; unsigned int captureCount_ = 0;