summaryrefslogtreecommitdiff
path: root/src/libcamera/framebuffer.cpp
diff options
context:
space:
mode:
authorLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-09-02 04:29:03 +0300
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2021-09-07 19:18:28 +0300
commit9df775c7574520632547c2f4db236b7d84f6e3c3 (patch)
treef3549960d4cf5a452cbe53f81fdc9b0bcdea0aae /src/libcamera/framebuffer.cpp
parent0f4d81c2bf40b1aba07dc5ef66aaa7484496eedf (diff)
libcamera: framebuffer: Allocate metadata planes at construction time
The metadata planes are allocated by V4L2VideoDevice when dequeuing a buffer. This causes the metadata planes to only be allocated after a buffer gets dequeued, and doesn't provide any strong guarantee that their number matches the number of FrameBuffer planes. The lack of this invariant makes the FrameBuffer class fragile. As a first step towards fixing this, allocate the metadata planes when the FrameBuffer is constructed. The FrameMetadata API should be further improved by preventing a change in the number of planes. Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Reviewed-by: Jean-Michel Hautbois <jeanmichel.hautbois@ideasonboard.com> Reviewed-by: Hirokazu Honda <hiroh@chromium.org>
Diffstat (limited to 'src/libcamera/framebuffer.cpp')
-rw-r--r--src/libcamera/framebuffer.cpp2
1 files changed, 2 insertions, 0 deletions
diff --git a/src/libcamera/framebuffer.cpp b/src/libcamera/framebuffer.cpp
index e71c2ffa..e4f8419a 100644
--- a/src/libcamera/framebuffer.cpp
+++ b/src/libcamera/framebuffer.cpp
@@ -210,6 +210,8 @@ FrameBuffer::FrameBuffer(const std::vector<Plane> &planes, unsigned int cookie)
: Extensible(std::make_unique<Private>()), planes_(planes),
cookie_(cookie)
{
+ metadata_.planes.resize(planes_.size());
+
unsigned int offset = 0;
bool isContiguous = true;
ino_t inode = 0;