From fca7602c3c88e804d1fbb5ae1372e2e6e841a4ee Mon Sep 17 00:00:00 2001 From: Laurent Pinchart Date: Thu, 28 Feb 2019 17:45:58 +0200 Subject: libcamera: buffer: Add buffer completion status MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Add a new field to the Buffer class to report its completion status, with a new cancel() method to mark the buffer as cancelled. Signed-off-by: Laurent Pinchart Reviewed-by: Niklas Söderlund --- src/libcamera/buffer.cpp | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) (limited to 'src/libcamera/buffer.cpp') diff --git a/src/libcamera/buffer.cpp b/src/libcamera/buffer.cpp index 80dd9c85..524eb47d 100644 --- a/src/libcamera/buffer.cpp +++ b/src/libcamera/buffer.cpp @@ -181,6 +181,20 @@ void *Plane::mem() * objects if the image format is multi-planar. */ +/** + * \enum Buffer::Status + * Buffer completion status + * \var Buffer::BufferSuccess + * The buffer has completed with success and contains valid data. All its other + * metadata (such as bytesused(), timestamp() or sequence() number) are valid. + * \var Buffer::BufferError + * The buffer has completed with an error and doesn't contain valid data. Its + * other metadata are valid. + * \var Buffer::BufferCancelled + * The buffer has been cancelled due to capture stop. Its other metadata are + * invalid and shall not be used. + */ + Buffer::Buffer() : index_(-1) { @@ -229,6 +243,27 @@ Buffer::Buffer() * \return Sequence number of the buffer */ +/** + * \fn Buffer::status() + * \brief Retrieve the buffer status + * + * The buffer status reports whether the buffer has completed successfully + * (BufferSuccess) or if an error occurred (BufferError). + * + * \return The buffer status + */ + +/** + * \brief Mark a buffer as cancel by setting its status to BufferCancelled + */ +void Buffer::cancel() +{ + bytesused_ = 0; + timestamp_ = 0; + sequence_ = 0; + status_ = BufferCancelled; +} + /** * \class BufferPool * \brief A pool of buffers -- cgit v1.2.1