From patchwork Wed Sep 10 15:18:57 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: 24302 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 63B42C324E for ; Wed, 10 Sep 2025 15:19:04 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id 142EC6936E; Wed, 10 Sep 2025 17:19:03 +0200 (CEST) Authentication-Results: lancelot.ideasonboard.com; dkim=pass (1024-bit key; unprotected) header.d=ideasonboard.com header.i=@ideasonboard.com header.b="fgcs67Uh"; dkim-atps=neutral Received: from perceval.ideasonboard.com (perceval.ideasonboard.com [213.167.242.64]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id A781469357 for ; Wed, 10 Sep 2025 17:19:01 +0200 (CEST) Received: from pb-laptop.local (185.221.142.115.nat.pool.zt.hu [185.221.142.115]) by perceval.ideasonboard.com (Postfix) with ESMTPSA id 85199928 for ; Wed, 10 Sep 2025 17:17:47 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=ideasonboard.com; s=mail; t=1757517467; bh=qc3Cu11i53bpW5n/pvTW7gl9yqhorVIuWRc5aNFiV5U=; h=From:To:Subject:Date:From; b=fgcs67UhH9rMu1+1mFLkfE6RL1ZPwy7le/WCAxq+KO3mZtpqz4hEw5twZLwQTyEvA FCua08+xuNUj7FnVe4OzeEZBnZGg610wi0fh3RJPQstzUiUZMatcou4U2/oBBnYylr 3TiSmsOPj/YSp5zmDeo3rVI4pzDox/yqwvBMaJoY= From: =?utf-8?q?Barnab=C3=A1s_P=C5=91cze?= To: libcamera-devel@lists.libcamera.org Subject: [PATCH v2] libcamera: request: addBuffer(): Do not destroy fence on failure Date: Wed, 10 Sep 2025 17:18:57 +0200 Message-ID: <20250910151857.1502329-1-barnabas.pocze@ideasonboard.com> X-Mailer: git-send-email 2.51.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" Take the unique pointer to the `Fence` object by rvalue reference so that it is not destroyed if the function returns an error code and does not take ownership of the unique pointer. Signed-off-by: Barnabás Pőcze Reviewed-by: Laurent Pinchart --- changes in v2: * modify function documentation v1: https://patchwork.libcamera.org/patch/22907/ --- include/libcamera/request.h | 2 +- src/libcamera/request.cpp | 6 ++++-- 2 files changed, 5 insertions(+), 3 deletions(-) -- 2.51.0 diff --git a/include/libcamera/request.h b/include/libcamera/request.h index e214a9d13..0c5939f7b 100644 --- a/include/libcamera/request.h +++ b/include/libcamera/request.h @@ -53,7 +53,7 @@ public: ControlList &metadata() { return *metadata_; } const BufferMap &buffers() const { return bufferMap_; } int addBuffer(const Stream *stream, FrameBuffer *buffer, - std::unique_ptr fence = nullptr); + std::unique_ptr &&fence = {}); FrameBuffer *findBuffer(const Stream *stream) const; uint32_t sequence() const; diff --git a/src/libcamera/request.cpp b/src/libcamera/request.cpp index 7f1e11e8f..26bba8f28 100644 --- a/src/libcamera/request.cpp +++ b/src/libcamera/request.cpp @@ -452,7 +452,9 @@ void Request::reuse(ReuseFlag flags) * * When a valid Fence is provided to this function, \a fence is moved to \a * buffer and this Request will only be queued to the device once the - * fences of all its buffers have been correctly signalled. + * fences of all its buffers have been correctly signalled. Ownership of the + * fence will only be taken in case of success, otherwise the fence will + * be left unmodified. * * If the \a fence associated with \a buffer isn't signalled, the request will * fail after a timeout. The buffer will still contain the fence, which @@ -468,7 +470,7 @@ void Request::reuse(ReuseFlag flags) * \retval -EINVAL The buffer does not reference a valid Stream */ int Request::addBuffer(const Stream *stream, FrameBuffer *buffer, - std::unique_ptr fence) + std::unique_ptr &&fence) { if (!stream) { LOG(Request, Error) << "Invalid stream reference";