From a0bf0e0686520865ecf8667b0ef92f604b5bdd59 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 29 Nov 2021 11:07:13 +0100 Subject: [PATCH] buffers: improve fallback memory allocation If one of the link ports is remote, enforce shared memory for the buffer data. We must not use MemPtr because it will not be possible to transfer this to the remote client. If none of the sides selected any buffer type but we need shared memory for the data, select MemFd as the fallback. This avoids using DmaBuf, that the client did not explicitly select. --- src/pipewire/buffers.c | 4 ++++ src/pipewire/buffers.h | 1 + src/pipewire/impl-link.c | 3 +++ 3 files changed, 8 insertions(+) diff --git a/src/pipewire/buffers.c b/src/pipewire/buffers.c index 1ba98b183..f15f75753 100644 --- a/src/pipewire/buffers.c +++ b/src/pipewire/buffers.c @@ -319,6 +319,10 @@ int pw_buffers_negotiate(struct pw_context *context, uint32_t flags, max_buffers = 2; } + if (types == SPA_ID_INVALID && + SPA_FLAG_IS_SET(flags, PW_BUFFERS_FLAG_SHARED_MEM)) + types = 1<node->remote || input->node->remote) + alloc_flags |= PW_BUFFERS_FLAG_SHARED_MEM; + /* if output port can alloc buffers, alloc skeleton buffers */ if (SPA_FLAG_IS_SET(out_flags, SPA_PORT_FLAG_CAN_ALLOC_BUFFERS)) { SPA_FLAG_SET(alloc_flags, PW_BUFFERS_FLAG_NO_MEM);