summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorNaushir Patuck <naush@raspberrypi.com>2022-03-25 09:09:02 +0000
committerLaurent Pinchart <laurent.pinchart@ideasonboard.com>2022-03-28 02:18:34 +0300
commit5704856681a0e9fc5eba7dd4af7f153a05e3db1a (patch)
tree91aea189bd7fc50ccf95f637de03d453c507a94a /src
parent1fb71a6ffa4c95661ecb5bf34e14bc80e47fc934 (diff)
libcamera: v4l2_videodevice: Empty the V4L2 buffer cache on streamOff()
When streamOff() is called, ensure the cache entries for the remaining queued buffers are freed since this will not happen via the dequeueBuffer() mechanism. Additionally, add a V4L2BufferCache::isEmpty() function and assert that the cache is empty at the end of the streamOff() call. Signed-off-by: Naushir Patuck <naush@raspberrypi.com> Tested-by: David Plowman <david.plowman@raspberrypi.com> Reviewed-by: Kieran Bingham <kieran.bingham@ideasonboard.com> Reviewed-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com> Signed-off-by: Laurent Pinchart <laurent.pinchart@ideasonboard.com>
Diffstat (limited to 'src')
-rw-r--r--src/libcamera/v4l2_videodevice.cpp16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libcamera/v4l2_videodevice.cpp b/src/libcamera/v4l2_videodevice.cpp
index 9b5807d3..009f6d55 100644
--- a/src/libcamera/v4l2_videodevice.cpp
+++ b/src/libcamera/v4l2_videodevice.cpp
@@ -202,6 +202,19 @@ V4L2BufferCache::~V4L2BufferCache()
}
/**
+ * \brief Check if all the entries in the cache are unused
+ */
+bool V4L2BufferCache::isEmpty() const
+{
+ for (auto const &entry : cache_) {
+ if (!entry.free_)
+ return false;
+ }
+
+ return true;
+}
+
+/**
* \brief Find the best V4L2 buffer for a FrameBuffer
* \param[in] buffer The FrameBuffer
*
@@ -1849,10 +1862,13 @@ int V4L2VideoDevice::streamOff()
for (auto it : queuedBuffers_) {
FrameBuffer *buffer = it.second;
+ cache_->put(it.first);
buffer->metadata_.status = FrameMetadata::FrameCancelled;
bufferReady.emit(buffer);
}
+ ASSERT(cache_->isEmpty());
+
queuedBuffers_.clear();
fdBufferNotifier_->setEnabled(false);
state_ = State::Stopped;