v4l2: increase by one the number of allocated buffers
authorGuillaume Desmottes <guillaume.desmottes@collabora.co.uk>
Wed, 24 May 2017 13:07:51 +0000 (15:07 +0200)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Thu, 29 Jun 2017 19:13:18 +0000 (15:13 -0400)
commit47ca2ce499de307faae1d25e22598429555ad0ab
tree41004bf36dc4faba2fff6f64ac3885aa1d820a67
parentcd17c71dcea5c9310d21f1347c7520983e5869ac
v4l2: increase by one the number of allocated buffers

Increasing this number fix a buffer starvation problem I'm hitting
with a "v4l2src ! kmssink" pipeline.

kmssink requests 2 buffer as it keeps a reference on the last rendered
one. So we were allocating 3 buffers for the pipeline.
Once the first 2 buffers have been pushed we ended up with:
- one buffer queued in v4l2
- one being pushed
- one kept as last rendered

If this 3rd buffer is released after that v4l2 used the first one to
capture we end up with a buffer starvation problem as no buffer is currently
queued in v4l2 for capture.

Fixing this by adding one extra buffer to the pipeline so when one
buffer is being pushed downstream the other can already be queued to
capture the next frame.

We were already adding 3 buffers if downstream didn't reply to the
allocation query. I reduced this number to 2 to compensate the extra
buffer which is now always added.

https://bugzilla.gnome.org/show_bug.cgi?id=783049
sys/v4l2/gstv4l2object.c