mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-01 22:58:50 -04:00
v4l2: fall back to mmap when EXPBUF fails
If EXPBUF returns and error, try to mmap instead. Fixes #294
This commit is contained in:
parent
cce8f3fb08
commit
59990ea049
1 changed files with 9 additions and 2 deletions
|
|
@ -1456,8 +1456,14 @@ mmap_init(struct impl *this,
|
||||||
expbuf.index = i;
|
expbuf.index = i;
|
||||||
expbuf.flags = O_CLOEXEC | O_RDONLY;
|
expbuf.flags = O_CLOEXEC | O_RDONLY;
|
||||||
if (xioctl(dev->fd, VIDIOC_EXPBUF, &expbuf) < 0) {
|
if (xioctl(dev->fd, VIDIOC_EXPBUF, &expbuf) < 0) {
|
||||||
|
if (errno == ENOTTY || errno == EINVAL) {
|
||||||
|
spa_log_debug(this->log, "v4l2: '%s' VIDIOC_EXPBUF not supported: %m",
|
||||||
|
this->props.device);
|
||||||
|
port->export_buf = false;
|
||||||
|
goto fallback;
|
||||||
|
}
|
||||||
spa_log_error(this->log, "v4l2: '%s' VIDIOC_EXPBUF: %m", this->props.device);
|
spa_log_error(this->log, "v4l2: '%s' VIDIOC_EXPBUF: %m", this->props.device);
|
||||||
continue;
|
return -errno;
|
||||||
}
|
}
|
||||||
d[0].type = SPA_DATA_DmaBuf;
|
d[0].type = SPA_DATA_DmaBuf;
|
||||||
d[0].flags = SPA_DATA_FLAG_READABLE;
|
d[0].flags = SPA_DATA_FLAG_READABLE;
|
||||||
|
|
@ -1466,6 +1472,7 @@ mmap_init(struct impl *this,
|
||||||
SPA_FLAG_SET(b->flags, BUFFER_FLAG_ALLOCATED);
|
SPA_FLAG_SET(b->flags, BUFFER_FLAG_ALLOCATED);
|
||||||
spa_log_debug(this->log, "v4l2: EXPBUF fd:%d", expbuf.fd);
|
spa_log_debug(this->log, "v4l2: EXPBUF fd:%d", expbuf.fd);
|
||||||
} else {
|
} else {
|
||||||
|
fallback:
|
||||||
d[0].type = SPA_DATA_MemPtr;
|
d[0].type = SPA_DATA_MemPtr;
|
||||||
d[0].flags = SPA_DATA_FLAG_READABLE;
|
d[0].flags = SPA_DATA_FLAG_READABLE;
|
||||||
d[0].fd = -1;
|
d[0].fd = -1;
|
||||||
|
|
@ -1476,7 +1483,7 @@ mmap_init(struct impl *this,
|
||||||
b->v4l2_buffer.m.offset);
|
b->v4l2_buffer.m.offset);
|
||||||
if (d[0].data == MAP_FAILED) {
|
if (d[0].data == MAP_FAILED) {
|
||||||
spa_log_error(this->log, "v4l2: '%s' mmap: %m", this->props.device);
|
spa_log_error(this->log, "v4l2: '%s' mmap: %m", this->props.device);
|
||||||
continue;
|
return -errno;
|
||||||
}
|
}
|
||||||
b->ptr = d[0].data;
|
b->ptr = d[0].data;
|
||||||
SPA_FLAG_SET(b->flags, BUFFER_FLAG_MAPPED);
|
SPA_FLAG_SET(b->flags, BUFFER_FLAG_MAPPED);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue