[libcamera-devel] [PATCH v4 3/9] libcamera: frame_buffer_allocator: Add freeAll()
Jacopo Mondi
jacopo at jmondi.org
Wed Sep 30 15:27:01 CEST 2020
Add a freeAll() method to the FrameBufferAllocator class that
frees all the buffers previously reserved by the allocator.
Reviewed-by: Laurent Pinchart <laurent.pinchart at ideasonboard.com>
Reviewed-by: Kieran Bingham <kieran.bingham at ideasonboard.com>
Reviewed-by: Hirokazu Honda <hiroh at chromium.org>
Reviewed-by: Niklas Söderlund <niklas.soderlund at ragnatech.se>
Signed-off-by: Jacopo Mondi <jacopo at jmondi.org>
---
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 a96aaeae58ce..3394e9923584 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 freeAll();
bool allocated() const { return !buffers_.empty(); }
const std::vector<std::unique_ptr<FrameBuffer>> &buffers(Stream *stream) const;
diff --git a/src/libcamera/framebuffer_allocator.cpp b/src/libcamera/framebuffer_allocator.cpp
index 2fbba37a1b0b..8dbe94ad1ce6 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::freeAll()
+{
+ buffers_.clear();
+}
+
/**
* \fn FrameBufferAllocator::allocated()
* \brief Check if the allocator has allocated buffers for any stream
--
2.28.0
More information about the libcamera-devel
mailing list