mirror of
https://git.libcamera.org/libcamera/libcamera.git
synced 2025-07-12 23:09:45 +03:00
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>
This commit is contained in:
parent
1fb71a6ffa
commit
5704856681
2 changed files with 17 additions and 0 deletions
|
@ -124,6 +124,7 @@ public:
|
|||
V4L2BufferCache(const std::vector<std::unique_ptr<FrameBuffer>> &buffers);
|
||||
~V4L2BufferCache();
|
||||
|
||||
bool isEmpty() const;
|
||||
int get(const FrameBuffer &buffer);
|
||||
void put(unsigned int index);
|
||||
|
||||
|
|
|
@ -201,6 +201,19 @@ V4L2BufferCache::~V4L2BufferCache()
|
|||
LOG(V4L2, Debug) << "Cache misses: " << missCounter_;
|
||||
}
|
||||
|
||||
/**
|
||||
* \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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue