diff --git a/src/modules/module-client-node/client-node.c b/src/modules/module-client-node/client-node.c index ba62058a4..95c2d8445 100644 --- a/src/modules/module-client-node/client-node.c +++ b/src/modules/module-client-node/client-node.c @@ -1209,6 +1209,7 @@ static void node_initialized(void *data) size = sizeof(struct spa_io_buffers) * MAX_AREAS; if (pw_mempool_alloc(impl->core->pool, + PW_MEMBLOCK_FLAG_READWRITE | PW_MEMBLOCK_FLAG_MAP | PW_MEMBLOCK_FLAG_SEAL, size, &impl->io_areas) < 0) diff --git a/src/pipewire/control.c b/src/pipewire/control.c index 48c2534f5..9b0568f4a 100644 --- a/src/pipewire/control.c +++ b/src/pipewire/control.c @@ -184,6 +184,7 @@ int pw_control_add_link(struct pw_control *control, uint32_t cmix, if (impl->mem == NULL) { if ((res = pw_mempool_alloc(control->core->pool, + PW_MEMBLOCK_FLAG_READWRITE | PW_MEMBLOCK_FLAG_SEAL | PW_MEMBLOCK_FLAG_MAP, size, &impl->mem)) < 0) diff --git a/src/pipewire/link.c b/src/pipewire/link.c index b7910fd1b..accada940 100644 --- a/src/pipewire/link.c +++ b/src/pipewire/link.c @@ -446,6 +446,7 @@ static int alloc_buffers(struct pw_link *this, bp = SPA_MEMBER(buffers, n_buffers * sizeof(struct spa_buffer *), struct spa_buffer); if ((res = pw_mempool_alloc(this->core->pool, + PW_MEMBLOCK_FLAG_READWRITE | PW_MEMBLOCK_FLAG_SEAL | PW_MEMBLOCK_FLAG_MAP, n_buffers * info.mem_size, &m)) < 0) diff --git a/src/pipewire/mem.c b/src/pipewire/mem.c index fa1d7e5dc..8728b7416 100644 --- a/src/pipewire/mem.c +++ b/src/pipewire/mem.c @@ -418,7 +418,7 @@ int pw_mempool_alloc(struct pw_mempool *pool, enum pw_memblock_flags flags, b->this.fd = memfd_create("pipewire-memfd", MFD_CLOEXEC | MFD_ALLOW_SEALING); if (b->this.fd == -1) { res = -errno; - pw_log_error("Failed to create memfd: %s\n", strerror(errno)); + pw_log_error("Failed to create memfd: %m"); goto error_free; } #else @@ -426,7 +426,7 @@ int pw_mempool_alloc(struct pw_mempool *pool, enum pw_memblock_flags flags, b->this.fd = mkostemp(filename, O_CLOEXEC); if (b->this.fd == -1) { res = -errno; - pw_log_error("Failed to create temporary file: %s\n", strerror(errno)); + pw_log_error("Failed to create temporary file: %m"); goto error_free; } unlink(filename); @@ -434,23 +434,31 @@ int pw_mempool_alloc(struct pw_mempool *pool, enum pw_memblock_flags flags, if (ftruncate(b->this.fd, size) < 0) { res = -errno; - pw_log_warn("Failed to truncate temporary file: %s", strerror(errno)); + pw_log_warn("Failed to truncate temporary file: %m"); goto error_close; } #ifdef USE_MEMFD if (flags & PW_MEMBLOCK_FLAG_SEAL) { unsigned int seals = F_SEAL_GROW | F_SEAL_SHRINK | F_SEAL_SEAL; if (fcntl(b->this.fd, F_ADD_SEALS, seals) == -1) { - pw_log_warn("Failed to add seals: %s", strerror(errno)); + pw_log_warn("Failed to add seals: %m"); } } #endif b->this.type = SPA_DATA_MemFd; if (flags & PW_MEMBLOCK_FLAG_MAP && size > 0) { - b->this.map = pw_memblock_map(&b->this, PROT_READ|PROT_WRITE, 0, size); + enum pw_memmap_flags fl = 0; + + if (flags & PW_MEMBLOCK_FLAG_READABLE) + fl |= PW_MEMMAP_FLAG_READ; + if (flags & PW_MEMBLOCK_FLAG_WRITABLE) + fl |= PW_MEMMAP_FLAG_WRITE; + + b->this.map = pw_memblock_map(&b->this, fl, 0, size); if (b->this.map == NULL) { res = -errno; + pw_log_warn("Failed to map: %m"); goto error_close; } } diff --git a/src/pipewire/node.c b/src/pipewire/node.c index 5e3b2cd88..7a66b9b18 100644 --- a/src/pipewire/node.c +++ b/src/pipewire/node.c @@ -863,6 +863,7 @@ struct pw_node *pw_node_new(struct pw_core *core, size = sizeof(struct pw_node_activation); if ((res = pw_mempool_alloc(this->core->pool, + PW_MEMBLOCK_FLAG_READWRITE | PW_MEMBLOCK_FLAG_SEAL | PW_MEMBLOCK_FLAG_MAP, size, &this->activation)) < 0)