v4l2: use a separate flag to skip the first buffer

The buf.sequence value might stay to 0 (v4l2loopback)
This commit is contained in:
Wim Taymans 2024-11-07 15:36:18 +01:00
parent cba2fad86b
commit 4c487ea59d
2 changed files with 7 additions and 2 deletions

View file

@ -75,6 +75,7 @@ struct port {
bool alloc_buffers;
bool probed_expbuf;
bool have_expbuf;
bool first_buffer;
uint32_t max_buffers;
bool next_fmtdesc;

View file

@ -1409,8 +1409,10 @@ static int mmap_read(struct impl *this)
/* Drop the first frame in order to work around common firmware
* timestamp issues */
if (buf.sequence == 0) {
xioctl(dev->fd, VIDIOC_QBUF, &buf);
if (port->first_buffer) {
port->first_buffer = false;
if (xioctl(dev->fd, VIDIOC_QBUF, &buf) < 0)
spa_log_warn(this->log, "v4l2 %p: error qbuf: %m", this);
return 0;
}
@ -1799,6 +1801,8 @@ static int spa_v4l2_stream_on(struct impl *this)
spa_log_debug(this->log, "starting");
port->first_buffer = true;
type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
if (xioctl(dev->fd, VIDIOC_STREAMON, &type) < 0) {
spa_log_error(this->log, "'%s' VIDIOC_STREAMON: %m", this->props.device);