v4l2: probe number of buffers as well

Instead of just probing with 2 buffers, probe with the MAX_BUFFERS and
remember how many buffers we received.

Some drivers (v4l2loopback) work with less than MAX_BUFFERS (8) and we
need to set the max number of buffers in the Buffers param.
This commit is contained in:
Wim Taymans 2024-11-07 15:33:04 +01:00
parent bfbf38d5f7
commit cba2fad86b
2 changed files with 7 additions and 2 deletions

View file

@ -911,12 +911,13 @@ static int probe_expbuf(struct impl *this)
spa_zero(reqbuf);
reqbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;
reqbuf.memory = V4L2_MEMORY_MMAP;
reqbuf.count = 2;
reqbuf.count = port->max_buffers = MAX_BUFFERS;
if (xioctl(dev->fd, VIDIOC_REQBUFS, &reqbuf) < 0) {
spa_log_error(this->log, "'%s' VIDIOC_REQBUFS: %m", this->props.device);
return -errno;
}
port->max_buffers = reqbuf.count;
spa_zero(expbuf);
expbuf.type = V4L2_BUF_TYPE_VIDEO_CAPTURE;