From 39ca1bb9edbebd6a57704d7aa92b61d9ee6e3f01 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 10 Apr 2024 13:11:54 +0200 Subject: [PATCH] mem: MAPPABLE -> UNMAPPABLE Change the flag from MAPPABLE to UNMAPPABLE to ease compatibility. Older servers with newer client will not set the flag and so memory is mappable for the client. Newer server will set the flag but the client will ignore it and act like before. --- src/modules/module-client-node/client-node.c | 5 ++--- src/modules/module-client-node/v0/transport.c | 1 - src/pipewire/buffers.c | 1 - src/pipewire/control.c | 1 - src/pipewire/core.h | 2 ++ src/pipewire/impl-client.c | 2 +- src/pipewire/impl-node.c | 1 - src/pipewire/mem.c | 2 +- src/pipewire/mem.h | 2 +- 9 files changed, 7 insertions(+), 10 deletions(-) diff --git a/src/modules/module-client-node/client-node.c b/src/modules/module-client-node/client-node.c index b3c32e133..7a1bb261f 100644 --- a/src/modules/module-client-node/client-node.c +++ b/src/modules/module-client-node/client-node.c @@ -859,8 +859,8 @@ do_port_use_buffers(struct impl *impl, { uint32_t flags = PW_MEMBLOCK_FLAG_DONT_CLOSE; - if (d->flags & SPA_DATA_FLAG_MAPPABLE) - flags |= PW_MEMBLOCK_FLAG_MAPPABLE; + if (!(d->flags & SPA_DATA_FLAG_MAPPABLE)) + flags |= PW_MEMBLOCK_FLAG_UNMAPPABLE; if (d->flags & SPA_DATA_FLAG_READABLE) flags |= PW_MEMBLOCK_FLAG_READABLE; if (d->flags & SPA_DATA_FLAG_WRITABLE) @@ -1357,7 +1357,6 @@ static int add_area(struct impl *impl) area = pw_mempool_alloc(impl->context_pool, PW_MEMBLOCK_FLAG_READWRITE | PW_MEMBLOCK_FLAG_SEAL | - PW_MEMBLOCK_FLAG_MAPPABLE | PW_MEMBLOCK_FLAG_MAP, SPA_DATA_MemFd, size); if (area == NULL) diff --git a/src/modules/module-client-node/v0/transport.c b/src/modules/module-client-node/v0/transport.c index 2e433eeec..d62f23ca2 100644 --- a/src/modules/module-client-node/v0/transport.c +++ b/src/modules/module-client-node/v0/transport.c @@ -192,7 +192,6 @@ pw_client_node0_transport_new(struct pw_context *context, impl->mem = pw_mempool_alloc(pw_context_get_mempool(context), PW_MEMBLOCK_FLAG_READWRITE | PW_MEMBLOCK_FLAG_SEAL | - PW_MEMBLOCK_FLAG_MAPPABLE | PW_MEMBLOCK_FLAG_MAP, SPA_DATA_MemFd, area_get_size(&area)); if (impl->mem == NULL) { diff --git a/src/pipewire/buffers.c b/src/pipewire/buffers.c index 5f6912441..e73adaaec 100644 --- a/src/pipewire/buffers.c +++ b/src/pipewire/buffers.c @@ -83,7 +83,6 @@ static int alloc_buffers(struct pw_mempool *pool, m = pw_mempool_alloc(pool, PW_MEMBLOCK_FLAG_READWRITE | PW_MEMBLOCK_FLAG_SEAL | - PW_MEMBLOCK_FLAG_MAPPABLE | PW_MEMBLOCK_FLAG_MAP, SPA_DATA_MemFd, n_buffers * info.mem_size); diff --git a/src/pipewire/control.c b/src/pipewire/control.c index 6222d9ba2..60324a35a 100644 --- a/src/pipewire/control.c +++ b/src/pipewire/control.c @@ -170,7 +170,6 @@ int pw_control_add_link(struct pw_control *control, uint32_t cmix, impl->mem = pw_mempool_alloc(control->context->pool, PW_MEMBLOCK_FLAG_READWRITE | PW_MEMBLOCK_FLAG_SEAL | - PW_MEMBLOCK_FLAG_MAPPABLE | PW_MEMBLOCK_FLAG_MAP, SPA_DATA_MemFd, size); if (impl->mem == NULL) { diff --git a/src/pipewire/core.h b/src/pipewire/core.h index c7f9ba65d..171d35d68 100644 --- a/src/pipewire/core.h +++ b/src/pipewire/core.h @@ -209,6 +209,8 @@ struct pw_core_events { * \param id bound object ID * \param global_id the global id bound to * \param props The properties of the new global object. + * + * Since version 4:1 */ void (*bound_props) (void *data, uint32_t id, uint32_t global_id, const struct spa_dict *props); }; diff --git a/src/pipewire/impl-client.c b/src/pipewire/impl-client.c index 167366c92..06e3d53bc 100644 --- a/src/pipewire/impl-client.c +++ b/src/pipewire/impl-client.c @@ -382,7 +382,7 @@ static void pool_added(void *data, struct pw_memblock *block) if (client->core_resource) { pw_core_resource_add_mem(client->core_resource, block->id, block->type, block->fd, - block->flags & (PW_MEMBLOCK_FLAG_READWRITE | PW_MEMBLOCK_FLAG_MAPPABLE)); + block->flags & (PW_MEMBLOCK_FLAG_READWRITE | PW_MEMBLOCK_FLAG_UNMAPPABLE)); } } diff --git a/src/pipewire/impl-node.c b/src/pipewire/impl-node.c index 1af48dd21..526e77c8b 100644 --- a/src/pipewire/impl-node.c +++ b/src/pipewire/impl-node.c @@ -1479,7 +1479,6 @@ struct pw_impl_node *pw_context_create_node(struct pw_context *context, this->activation = pw_mempool_alloc(this->context->pool, PW_MEMBLOCK_FLAG_READWRITE | PW_MEMBLOCK_FLAG_SEAL | - PW_MEMBLOCK_FLAG_MAPPABLE | PW_MEMBLOCK_FLAG_MAP, SPA_DATA_MemFd, size); if (this->activation == NULL) { diff --git a/src/pipewire/mem.c b/src/pipewire/mem.c index 8b5362698..f24083849 100644 --- a/src/pipewire/mem.c +++ b/src/pipewire/mem.c @@ -323,7 +323,7 @@ static struct mapping * memblock_map(struct memblock *b, return NULL; } - if (!(b->this.flags & PW_MEMBLOCK_FLAG_MAPPABLE)) { + if ((b->this.flags & PW_MEMBLOCK_FLAG_UNMAPPABLE)) { pw_log_error("%p: block:%p can't be mmaped", p, &b->this); errno = EPERM; return NULL; diff --git a/src/pipewire/mem.h b/src/pipewire/mem.h index fe3a63e04..8ce57bd91 100644 --- a/src/pipewire/mem.h +++ b/src/pipewire/mem.h @@ -29,7 +29,7 @@ enum pw_memblock_flags { PW_MEMBLOCK_FLAG_MAP = (1 << 3), /**< mmap the fd */ PW_MEMBLOCK_FLAG_DONT_CLOSE = (1 << 4), /**< don't close fd */ PW_MEMBLOCK_FLAG_DONT_NOTIFY = (1 << 5), /**< don't notify events */ - PW_MEMBLOCK_FLAG_MAPPABLE = (1 << 6), /**< the fd can be mmapped */ + PW_MEMBLOCK_FLAG_UNMAPPABLE = (1 << 6), /**< the fd can not be mmapped */ PW_MEMBLOCK_FLAG_READWRITE = PW_MEMBLOCK_FLAG_READABLE | PW_MEMBLOCK_FLAG_WRITABLE, };