Skip to content

Commit

Permalink
RASPBERRYPI ONLY: libcamera: v4l2_videodevice: Limit number of queued…
Browse files Browse the repository at this point in the history
… buffers

V4L2 only allows upto VIDEO_MAX_FRAME frames to be queued at a time, so
if we reach this limit, store the framebuffers in a pending queue, and
try to enqueue once a buffer has been dequeued.

Signed-off-by: Naushir Patuck <[email protected]>
  • Loading branch information
naushir committed Aug 28, 2024
1 parent 06a2f5c commit eb29254
Show file tree
Hide file tree
Showing 2 changed files with 203 additions and 136 deletions.
4 changes: 4 additions & 0 deletions include/libcamera/internal/v4l2_videodevice.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include <memory>
#include <optional>
#include <ostream>
#include <queue>
#include <stdint.h>
#include <string>
#include <unordered_set>
Expand Down Expand Up @@ -266,6 +267,8 @@ class V4L2VideoDevice : public V4L2Device
void bufferAvailable();
FrameBuffer *dequeueBuffer();

int queueToDevice(FrameBuffer *buffer);

void watchdogExpired();

template<typename T>
Expand All @@ -281,6 +284,7 @@ class V4L2VideoDevice : public V4L2Device

V4L2BufferCache *cache_;
std::map<unsigned int, FrameBuffer *> queuedBuffers_;
std::queue<FrameBuffer *> pendingBuffersToQueue_;

EventNotifier *fdBufferNotifier_;

Expand Down
Loading

0 comments on commit eb29254

Please sign in to comment.