mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-31 22:25:38 -04:00
v4l2: detect driver reusing buffers
Some drivers seem to only use 2 buffers when asked for 16 buffers. We can see this because the buffer is already queued. In this case, just use the 2 buffers. See #294
This commit is contained in:
parent
2df10d1a40
commit
ed1ee3f164
1 changed files with 12 additions and 5 deletions
|
|
@ -1407,13 +1407,13 @@ mmap_init(struct impl *this,
|
|||
spa_log_debug(this->log, "v4l2: got %d buffers", reqbuf.count);
|
||||
n_buffers = reqbuf.count;
|
||||
|
||||
if (reqbuf.count < 2) {
|
||||
if (n_buffers < 2) {
|
||||
spa_log_error(this->log, "v4l2: '%s' can't allocate enough buffers (%d)",
|
||||
this->props.device, reqbuf.count);
|
||||
this->props.device, n_buffers);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
for (i = 0; i < reqbuf.count; i++) {
|
||||
for (i = 0; i < n_buffers; i++) {
|
||||
struct buffer *b;
|
||||
struct spa_data *d;
|
||||
|
||||
|
|
@ -1438,6 +1438,13 @@ mmap_init(struct impl *this,
|
|||
return -errno;
|
||||
}
|
||||
|
||||
if (b->v4l2_buffer.flags & V4L2_BUF_FLAG_QUEUED) {
|
||||
/* some drivers can give us an already queued buffer. */
|
||||
spa_log_warn(this->log, "v4l2: buffer %d was already queued", i);
|
||||
n_buffers = i;
|
||||
break;
|
||||
}
|
||||
|
||||
d = buffers[i]->datas;
|
||||
d[0].mapoffset = 0;
|
||||
d[0].maxsize = b->v4l2_buffer.length;
|
||||
|
|
@ -1479,10 +1486,10 @@ fallback:
|
|||
}
|
||||
spa_v4l2_buffer_recycle(this, i);
|
||||
}
|
||||
spa_log_info(this->log, "v4l2: have %u buffers using %s", reqbuf.count,
|
||||
spa_log_info(this->log, "v4l2: have %u buffers using %s", n_buffers,
|
||||
port->have_expbuf ? "EXPBUF" : "MMAP");
|
||||
|
||||
port->n_buffers = reqbuf.count;
|
||||
port->n_buffers = n_buffers;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue