From patchwork Mon Mar 31 14:17:12 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: 23070 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 8B3D8C323E for ; Mon, 31 Mar 2025 14:17:24 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 348AD6897E; Mon, 31 Mar 2025 16:17:23 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="kQh7lUNQ"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [IPv6:2001:4b98:dc2:55:216:3eff:fef7:d647]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 8A53568967 for ; Mon, 31 Mar 2025 16:17:21 +0200 (CEST) Received: from pb-laptop.local (185.221.143.221.nat.pool.zt.hu [185.221.143.221]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id EC564725 for ; Mon, 31 Mar 2025 16:15:29 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1743430530; bh=/2TDMo6sy3rw/LK2jyYrToXT3X8XIktbQVzSeHDe6yI=; h=From:To:Subject:Date:From; b=kQh7lUNQ7NdU0SVBg/zolj2injyDPHY6haIFWOuTxPD5e9wT/zbKCvZM1nKQT08+v r1eTPDP/5YRbGl4GCvRGICL4Qt8glfElgy5+8tBDMWX1tclmzB0YKF5jv1GPIXkpE1 L9W8AeCniYVo28lz3pUdsKFxwdMA0r0qNgtJ2GF4= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v2 1/3] libcamera: request: Make `controls_`/`metadata_` members Date: Mon, 31 Mar 2025 16:17:12 +0200 Message-ID: <20250331141714.512538-1-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.49.0 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" The lifetimes of these two `ControlList`s are tied entirely to the request object, so simplify the code by making them member variables instead of manually managing their dynamic lifetime. Signed-off-by: Barnabás Pőcze Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- include/libcamera/request.h | 8 ++++---- src/libcamera/request.cpp | 17 ++++------------- 2 files changed, 8 insertions(+), 17 deletions(-) diff --git a/include/libcamera/request.h b/include/libcamera/request.h index e214a9d13..3061e2fb0 100644 --- a/include/libcamera/request.h +++ b/include/libcamera/request.h @@ -49,8 +49,8 @@ public: void reuse(ReuseFlag flags = Default); - ControlList &controls() { return *controls_; } - ControlList &metadata() { return *metadata_; } + ControlList &controls() { return controls_; } + ControlList &metadata() { return metadata_; } const BufferMap &buffers() const { return bufferMap_; } int addBuffer(const Stream *stream, FrameBuffer *buffer, std::unique_ptr fence = nullptr); @@ -67,8 +67,8 @@ public: private: LIBCAMERA_DISABLE_COPY(Request) - ControlList *controls_; - ControlList *metadata_; + ControlList controls_; + ControlList metadata_; BufferMap bufferMap_; const uint64_t cookie_; diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp index b206ac132..e7eb1c0c8 100644 --- a/src/libcamera/request.cpp +++ b/src/libcamera/request.cpp @@ -354,16 +354,10 @@ void Request::Private::timeout() */ Request::Request(Camera *camera, uint64_t cookie) : Extensible(std::make_unique(camera)), + controls_(controls::controls, camera->_d()->validator()), + metadata_(controls::controls), /* \todo Add a validator for metadata controls. */ cookie_(cookie), status_(RequestPending) { - controls_ = new ControlList(controls::controls, - camera->_d()->validator()); - - /** - * \todo Add a validator for metadata controls. - */ - metadata_ = new ControlList(controls::controls); - LIBCAMERA_TRACEPOINT(request_construct, this); LOG(Request, Debug) << "Created request - cookie: " << cookie_; @@ -372,9 +366,6 @@ Request::Request(Camera *camera, uint64_t cookie) Request::~Request() { LIBCAMERA_TRACEPOINT(request_destroy, this); - - delete metadata_; - delete controls_; } /** @@ -405,8 +396,8 @@ void Request::reuse(ReuseFlag flags) status_ = RequestPending; - controls_->clear(); - metadata_->clear(); + controls_.clear(); + metadata_.clear(); } /**