mem: add a PW_MEMBLOCK_FLAG_MAPPABLE flag and pass it around

This flags means that the fd can be mmaped without special handling. It
is the equivalent of the SPA_DATA_FLAG_MAPPABLE. Refuse to map memory
that is not mappable.

Make sure we make all allocated MemFd memory MAPPABLE by default. We can
then remove the stream and filter special handling for MemFd types and
just check the more generic MAPPABLE flag.

Make one exception when a client uploads MemFd buffer memory. We must
manually set the MAPPABLE flag for MemFd to make things backwards
compatible.
This commit is contained in:
Wim Taymans 2024-04-02 10:44:06 +02:00
parent 45984fef77
commit 2f8740dee8
12 changed files with 63 additions and 38 deletions

View file

@ -701,14 +701,14 @@ client_node_port_use_buffers(void *_data,
d->type = bm->type;
d->data = NULL;
pw_log_debug(" data %d %u -> fd %d maxsize %d",
j, bm->id, bm->fd, d->maxsize);
pw_log_debug(" data %d %u -> fd %d maxsize %d flags:%08x",
j, bm->id, bm->fd, d->maxsize, d->flags);
} else if (d->type == SPA_DATA_MemPtr) {
int offs = SPA_PTR_TO_INT(d->data);
d->data = SPA_PTROFF(mm->ptr, offs, void);
d->fd = -1;
pw_log_debug(" data %d id:%u -> mem:%p offs:%d maxsize:%d",
j, bid->id, d->data, offs, d->maxsize);
pw_log_debug(" data %d id:%u -> mem:%p offs:%d maxsize:%d flags:%08x",
j, bid->id, d->data, offs, d->maxsize, d->flags);
} else {
pw_log_warn("unknown buffer data type %d", d->type);
}