mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
v4l2: don't mmap when the buffer has data already
When the buffer has data (but no fd), don't mmap the buffer but simply use the data pointer directly. This makes v4l2 work with inlined buffer memory.
This commit is contained in:
parent
6bae31e519
commit
6cffabd09d
1 changed files with 15 additions and 3 deletions
|
|
@ -1290,6 +1290,7 @@ static void on_stream_param_changed(void *data, uint32_t id, const struct spa_po
|
||||||
SPA_PARAM_BUFFERS_stride, SPA_POD_CHOICE_RANGE_Int(stride, 0, INT_MAX),
|
SPA_PARAM_BUFFERS_stride, SPA_POD_CHOICE_RANGE_Int(stride, 0, INT_MAX),
|
||||||
SPA_PARAM_BUFFERS_dataType, SPA_POD_CHOICE_FLAGS_Int((1<<SPA_DATA_MemFd)));
|
SPA_PARAM_BUFFERS_dataType, SPA_POD_CHOICE_FLAGS_Int((1<<SPA_DATA_MemFd)));
|
||||||
|
|
||||||
|
|
||||||
pw_stream_update_params(file->stream, params, n_params);
|
pw_stream_update_params(file->stream, params, n_params);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
@ -2133,7 +2134,10 @@ static void *v4l2_mmap(void *addr, size_t length, int prot,
|
||||||
if (!SPA_FLAG_IS_SET(data->flags, SPA_DATA_FLAG_WRITABLE))
|
if (!SPA_FLAG_IS_SET(data->flags, SPA_DATA_FLAG_WRITABLE))
|
||||||
prot &= ~PROT_WRITE;
|
prot &= ~PROT_WRITE;
|
||||||
|
|
||||||
res = globals.old_fops.mmap(addr, range.size, prot, flags, data->fd, range.offset);
|
if (data->data == NULL)
|
||||||
|
res = globals.old_fops.mmap(addr, range.size, prot, flags, data->fd, range.offset);
|
||||||
|
else
|
||||||
|
res = data->data;
|
||||||
|
|
||||||
add_file_map(file, res);
|
add_file_map(file, res);
|
||||||
add_buffer_map(file, res, id);
|
add_buffer_map(file, res, id);
|
||||||
|
|
@ -2153,7 +2157,9 @@ static int v4l2_munmap(void *addr, size_t length)
|
||||||
{
|
{
|
||||||
int res;
|
int res;
|
||||||
struct buffer_map *bmap;
|
struct buffer_map *bmap;
|
||||||
|
struct buffer *buf;
|
||||||
struct file *file;
|
struct file *file;
|
||||||
|
struct spa_data *data;
|
||||||
|
|
||||||
if ((file = remove_file_map(addr)) == NULL)
|
if ((file = remove_file_map(addr)) == NULL)
|
||||||
return globals.old_fops.munmap(addr, length);
|
return globals.old_fops.munmap(addr, length);
|
||||||
|
|
@ -2165,12 +2171,18 @@ static int v4l2_munmap(void *addr, size_t length)
|
||||||
res = -EINVAL;
|
res = -EINVAL;
|
||||||
goto exit_unlock;
|
goto exit_unlock;
|
||||||
}
|
}
|
||||||
res = globals.old_fops.munmap(addr, length);
|
buf = &file->buffers[bmap->id];
|
||||||
|
data = &buf->buf->buffer->datas[0];
|
||||||
|
|
||||||
|
if (data->data == NULL)
|
||||||
|
res = globals.old_fops.munmap(addr, length);
|
||||||
|
else
|
||||||
|
res = 0;
|
||||||
|
|
||||||
pw_log_info("addr:%p length:%zu -> %d (%s)", addr, length,
|
pw_log_info("addr:%p length:%zu -> %d (%s)", addr, length,
|
||||||
res, strerror(res < 0 ? errno : 0));
|
res, strerror(res < 0 ? errno : 0));
|
||||||
|
|
||||||
file->buffers[bmap->id].v4l2.flags &= ~V4L2_BUF_FLAG_MAPPED;
|
buf->v4l2.flags &= ~V4L2_BUF_FLAG_MAPPED;
|
||||||
remove_buffer_map(file, bmap);
|
remove_buffer_map(file, bmap);
|
||||||
|
|
||||||
exit_unlock:
|
exit_unlock:
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue