From d3bd687bc2c4bd05a374f014a95570b293a87417 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Thu, 30 Mar 2023 14:53:44 +0200 Subject: [PATCH] buffers: add new ASYNC flag Make sure we allocate at least 2 buffers when we are dealing with an ASYNC node. This ensures that an adapter without a converter will at least negotiate to 2 buffers when the follower stream is async (such as is the case with pw-cat). --- src/pipewire/buffers.c | 4 ++++ src/pipewire/buffers.h | 1 + src/pipewire/impl-port.c | 7 +++++-- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/src/pipewire/buffers.c b/src/pipewire/buffers.c index 8c9d9dd58..75896b691 100644 --- a/src/pipewire/buffers.c +++ b/src/pipewire/buffers.c @@ -292,6 +292,9 @@ int pw_buffers_negotiate(struct pw_context *context, uint32_t flags, align = SPA_MAX(align, qalign); types = qtypes; + if (SPA_FLAG_IS_SET(flags, PW_BUFFERS_FLAG_ASYNC)) + max_buffers = SPA_MAX(2u, max_buffers); + pw_log_debug("%p: %d %d %d %d %d %d -> %d %zd %zd %d %zd %d", result, qblocks, qminsize, qstride, qmax_buffers, qalign, qtypes, blocks, minsize, stride, max_buffers, align, types); @@ -300,6 +303,7 @@ int pw_buffers_negotiate(struct pw_context *context, uint32_t flags, minsize = 8192; max_buffers = 2; } + if (SPA_FLAG_IS_SET(flags, PW_BUFFERS_FLAG_SHARED_MEM)) { if (types != SPA_ID_INVALID) SPA_FLAG_CLEAR(types, 1<spa_flags, SPA_NODE_FLAG_ASYNC)) + alloc_flags |= PW_BUFFERS_FLAG_ASYNC; - pw_log_debug("%p: %d.%d negotiate %d buffers on node: %p", - port, port->direction, port->port_id, n_buffers, node->node); + pw_log_debug("%p: %d.%d negotiate %d buffers on node: %p flags:%08x", + port, port->direction, port->port_id, n_buffers, node->node, + alloc_flags); if (port->added) { pw_loop_invoke(node->data_loop, do_remove_port, SPA_ID_INVALID, NULL, 0, true, port);