mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-13 13:30:05 -05:00
buffer: add option to reverse filter priority
By default, buffer negotiation favours the default property values of the output node. Make this configurable and reverse this logic when the output is a driver. This makes it so that a stream connecting to a source will negotiate with the preferences of the stream and not the source. An example is a stream that wants 4 buffers from v4l2-source, because v4l2-source has a default of 4 buffers, this will always result in 4 buffers, ignoring the preference of the stream.
This commit is contained in:
parent
503bb94645
commit
7631316186
3 changed files with 10 additions and 0 deletions
|
|
@ -255,6 +255,12 @@ int pw_buffers_negotiate(struct pw_context *context, uint32_t flags,
|
||||||
struct port input = { innode, SPA_DIRECTION_INPUT, in_port_id };
|
struct port input = { innode, SPA_DIRECTION_INPUT, in_port_id };
|
||||||
int res;
|
int res;
|
||||||
|
|
||||||
|
if (flags & PW_BUFFERS_FLAG_IN_PRIORITY) {
|
||||||
|
struct port tmp = output;
|
||||||
|
output = input;
|
||||||
|
input = tmp;
|
||||||
|
}
|
||||||
|
|
||||||
res = param_filter(result, &input, &output, SPA_PARAM_Buffers, &b);
|
res = param_filter(result, &input, &output, SPA_PARAM_Buffers, &b);
|
||||||
if (res < 0) {
|
if (res < 0) {
|
||||||
pw_context_debug_port_params(context, input.node, input.direction,
|
pw_context_debug_port_params(context, input.node, input.direction,
|
||||||
|
|
|
||||||
|
|
@ -48,6 +48,7 @@ extern "C" {
|
||||||
#define PW_BUFFERS_FLAG_SHARED (1<<1) /**< buffers can be shared */
|
#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_DYNAMIC (1<<2) /**< buffers have dynamic data */
|
||||||
#define PW_BUFFERS_FLAG_SHARED_MEM (1<<3) /**< buffers need shared memory */
|
#define PW_BUFFERS_FLAG_SHARED_MEM (1<<3) /**< buffers need shared memory */
|
||||||
|
#define PW_BUFFERS_FLAG_IN_PRIORITY (1<<4) /**< input parameters have priority */
|
||||||
|
|
||||||
struct pw_buffers {
|
struct pw_buffers {
|
||||||
struct pw_memblock *mem; /**< allocated buffer memory */
|
struct pw_memblock *mem; /**< allocated buffer memory */
|
||||||
|
|
|
||||||
|
|
@ -517,6 +517,9 @@ static int do_allocation(struct pw_impl_link *this)
|
||||||
if (output->node->remote || input->node->remote)
|
if (output->node->remote || input->node->remote)
|
||||||
alloc_flags |= PW_BUFFERS_FLAG_SHARED_MEM;
|
alloc_flags |= PW_BUFFERS_FLAG_SHARED_MEM;
|
||||||
|
|
||||||
|
if (output->node->driver)
|
||||||
|
alloc_flags |= PW_BUFFERS_FLAG_IN_PRIORITY;
|
||||||
|
|
||||||
/* if output port can alloc buffers, alloc skeleton buffers */
|
/* if output port can alloc buffers, alloc skeleton buffers */
|
||||||
if (SPA_FLAG_IS_SET(out_flags, SPA_PORT_FLAG_CAN_ALLOC_BUFFERS)) {
|
if (SPA_FLAG_IS_SET(out_flags, SPA_PORT_FLAG_CAN_ALLOC_BUFFERS)) {
|
||||||
SPA_FLAG_SET(alloc_flags, PW_BUFFERS_FLAG_NO_MEM);
|
SPA_FLAG_SET(alloc_flags, PW_BUFFERS_FLAG_NO_MEM);
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue