From 887dbdb43978ecae4407d1a916075757bbaaa51d Mon Sep 17 00:00:00 2001 From: Hirokazu Honda Date: Thu, 26 Aug 2021 20:25:39 +0900 Subject: libcamera: framebuffer: Add assertion to detect offset is unfilled The offset variable is introduced to FrameBuffer::Plane. In order to detect that the plane is used while the offset is not set, this adds the assertion to FrameBuffer::planes(). It should be removed in the future. Signed-off-by: Hirokazu Honda Reviewed-by: Laurent Pinchart Signed-off-by: Laurent Pinchart --- include/libcamera/framebuffer.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/libcamera/framebuffer.h b/include/libcamera/framebuffer.h index 5de3c744..d5aeff00 100644 --- a/include/libcamera/framebuffer.h +++ b/include/libcamera/framebuffer.h @@ -7,6 +7,8 @@ #ifndef __LIBCAMERA_FRAMEBUFFER_H__ #define __LIBCAMERA_FRAMEBUFFER_H__ +#include +#include #include #include @@ -41,14 +43,21 @@ class FrameBuffer final : public Extensible public: struct Plane { + static constexpr unsigned int kInvalidOffset = std::numeric_limits::max(); FileDescriptor fd; - unsigned int offset; + unsigned int offset = kInvalidOffset; unsigned int length; }; FrameBuffer(const std::vector &planes, unsigned int cookie = 0); - const std::vector &planes() const { return planes_; } + const std::vector &planes() const + { + /* \todo Remove the assertions after sufficient testing */ + for (const auto &plane : planes_) + assert(plane.offset != Plane::kInvalidOffset); + return planes_; + } Request *request() const; const FrameMetadata &metadata() const { return metadata_; } -- cgit v1.2.1