From patchwork Tue Sep 22 09:47:33 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Jacopo Mondi X-Patchwork-Id: 9687 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 D3F5ABF01C for ; Tue, 22 Sep 2020 09:44:11 +0000 (UTC) Received: from lancelot.ideasonboard.com (localhost [IPv6:::1]) by lancelot.ideasonboard.com (Postfix) with ESMTP id B220F62FD4; Tue, 22 Sep 2020 11:44:11 +0200 (CEST) Received: from relay4-d.mail.gandi.net (relay4-d.mail.gandi.net [217.70.183.196]) by lancelot.ideasonboard.com (Postfix) with ESMTPS id 0F86160364 for ; Tue, 22 Sep 2020 11:44:11 +0200 (CEST) X-Originating-IP: 93.34.118.233 Received: from uno.lan (93-34-118-233.ip49.fastwebnet.it [93.34.118.233]) (Authenticated sender: jacopo@jmondi.org) by relay4-d.mail.gandi.net (Postfix) with ESMTPSA id 743CBE000D; Tue, 22 Sep 2020 09:44:05 +0000 (UTC) From: Jacopo Mondi To: libcamera-devel@lists.libcamera.org Date: Tue, 22 Sep 2020 11:47:33 +0200 Message-Id: <20200922094738.5327-4-jacopo@jmondi.org> X-Mailer: git-send-email 2.28.0 In-Reply-To: <20200922094738.5327-1-jacopo@jmondi.org> References: <20200922094738.5327-1-jacopo@jmondi.org> MIME-Version: 1.0 Subject: [libcamera-devel] [PATCH v3 3/8] libcamera: frame_buffer_allocator: Add clear() 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: , Cc: hanlinchen@chromium.org Errors-To: libcamera-devel-bounces@lists.libcamera.org Sender: "libcamera-devel" Add a clear() method to the FrameBufferAllocator class that frees all the buffers previously reserved by the allocator. Reviewed-by: Hirokazu Honda Reviewed-by: Niklas Söderlund Signed-off-by: Jacopo Mondi Reviewed-by: Kieran Bingham Reviewed-by: Laurent Pinchart --- include/libcamera/framebuffer_allocator.h | 1 + src/libcamera/framebuffer_allocator.cpp | 8 ++++++++ 2 files changed, 9 insertions(+) diff --git a/include/libcamera/framebuffer_allocator.h b/include/libcamera/framebuffer_allocator.h index 78f1353964eb..2a4d538a0cb2 100644 --- a/include/libcamera/framebuffer_allocator.h +++ b/include/libcamera/framebuffer_allocator.h @@ -28,6 +28,7 @@ public: int allocate(Stream *stream); int free(Stream *stream); + void clear(); bool allocated() const { return !buffers_.empty(); } const std::vector> &buffers(Stream *stream) const; diff --git a/src/libcamera/framebuffer_allocator.cpp b/src/libcamera/framebuffer_allocator.cpp index 2fbba37a1b0b..7ed80011c845 100644 --- a/src/libcamera/framebuffer_allocator.cpp +++ b/src/libcamera/framebuffer_allocator.cpp @@ -125,6 +125,14 @@ int FrameBufferAllocator::free(Stream *stream) return 0; } +/** + * \brief Free all the buffers previously allocated + */ +void FrameBufferAllocator::clear() +{ + buffers_.clear(); +} + /** * \fn FrameBufferAllocator::allocated() * \brief Check if the allocator has allocated buffers for any stream