mirror of
https://gitlab.freedesktop.org/pipewire/pipewire
synced 2024-09-19 16:01:45 +00:00
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.
This commit is contained in:
parent
cff8ac0cab
commit
a0bf0e0686
|
@ -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<<SPA_DATA_MemFd;
|
||||
|
||||
if (SPA_FLAG_IS_SET(flags, PW_BUFFERS_FLAG_NO_MEM))
|
||||
minsize = 0;
|
||||
|
||||
|
|
|
@ -47,6 +47,7 @@ extern "C" {
|
|||
#define PW_BUFFERS_FLAG_NO_MEM (1<<0) /**< don't allocate buffer memory */
|
||||
#define PW_BUFFERS_FLAG_SHARED (1<<1) /**< buffers can be shared */
|
||||
#define PW_BUFFERS_FLAG_DYNAMIC (1<<2) /**< buffers have dynamic data */
|
||||
#define PW_BUFFERS_FLAG_SHARED_MEM (1<<3) /**< buffers need shared memory */
|
||||
|
||||
struct pw_buffers {
|
||||
struct pw_memblock *mem; /**< allocated buffer memory */
|
||||
|
|
|
@ -516,6 +516,9 @@ static int do_allocation(struct pw_impl_link *this)
|
|||
flags = 0;
|
||||
/* always shared buffers for the link */
|
||||
alloc_flags = PW_BUFFERS_FLAG_SHARED;
|
||||
if (output->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);
|
||||
|
|
Loading…
Reference in a new issue