From f0eb59bc75f795f6a9bf7e2c984644d9b271e7a1 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 6 Mar 2019 10:30:27 +0100 Subject: [PATCH] port: allocate only from output ports We don't need to use the mix_id to allocate, the allocation is always shared between all output mixer ports --- src/pipewire/link.c | 1 - src/pipewire/port.c | 37 +++++++++++++++++-------------------- src/pipewire/private.h | 2 +- 3 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/pipewire/link.c b/src/pipewire/link.c index ae2c91d39..4bcc8b84d 100644 --- a/src/pipewire/link.c +++ b/src/pipewire/link.c @@ -676,7 +676,6 @@ static int do_allocation(struct pw_link *this) if (out_flags & SPA_PORT_FLAG_CAN_ALLOC_BUFFERS) { if ((res = pw_port_alloc_buffers(output, - this->rt.out_mix.port.port_id, params, n_params, allocation.buffers, &allocation.n_buffers)) < 0) { diff --git a/src/pipewire/port.c b/src/pipewire/port.c index 50e4e3b9f..35ad446fc 100644 --- a/src/pipewire/port.c +++ b/src/pipewire/port.c @@ -978,7 +978,7 @@ int pw_port_use_buffers(struct pw_port *port, uint32_t mix_id, } if (n_buffers == 0) { - if (port->n_mix == 0) + if (port->n_mix == 1) pw_port_update_state(port, PW_PORT_STATE_READY); } if (port->state == PW_PORT_STATE_READY) { @@ -1001,37 +1001,34 @@ int pw_port_use_buffers(struct pw_port *port, uint32_t mix_id, } SPA_EXPORT -int pw_port_alloc_buffers(struct pw_port *port, uint32_t mix_id, +int pw_port_alloc_buffers(struct pw_port *port, struct spa_pod **params, uint32_t n_params, struct spa_buffer **buffers, uint32_t *n_buffers) { int res; struct pw_node *node = port->node; - struct pw_port_mix *mix; const struct pw_port_implementation *pi = port->implementation; if (port->state < PW_PORT_STATE_READY) return -EIO; - if ((mix = pw_map_lookup(&port->mix_port_map, mix_id)) == NULL) - return -EIO; - - if (port->mix->port_alloc_buffers) { - struct spa_graph_port *p = &mix->port; - res = spa_node_port_alloc_buffers(port->mix, p->direction, p->port_id, - params, n_params, - buffers, n_buffers); - } else { - res = spa_node_port_alloc_buffers(node->node, port->direction, port->port_id, - params, n_params, - buffers, n_buffers); + if ((res = spa_node_port_alloc_buffers(node->node, port->direction, port->port_id, + params, n_params, + buffers, n_buffers)) < 0) { + pw_log_error("port %p: %d alloc failed: %d (%s)", port, port->port_id, + res, spa_strerror(res)); } - if (pi && pi->alloc_buffers) - res = pi->alloc_buffers(port->implementation_data, params, n_params, buffers, n_buffers); + if (res >= 0 && pi && pi->alloc_buffers) { + if ((res = pi->alloc_buffers(port->implementation_data, + params, n_params, buffers, n_buffers)) < 0) { + pw_log_error("port %p: %d implementation alloc failed: %d (%s)", + port, port->port_id, res, spa_strerror(res)); + } + } - pw_log_debug("port %p: %d.%d alloc %d buffers: %d (%s)", port, - port->port_id, mix_id, *n_buffers, res, spa_strerror(res)); + pw_log_debug("port %p: %d alloc %d buffers: %d (%s)", port, + port->port_id, *n_buffers, res, spa_strerror(res)); free_allocation(&port->allocation); @@ -1043,7 +1040,7 @@ int pw_port_alloc_buffers(struct pw_port *port, uint32_t mix_id, } if (*n_buffers == 0) { - if (port->n_mix == 0) + if (port->n_mix == 1) pw_port_update_state(port, PW_PORT_STATE_READY); } else if (!SPA_RESULT_IS_ASYNC(res)) { diff --git a/src/pipewire/private.h b/src/pipewire/private.h index c6c189c8f..e7e54876f 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -778,7 +778,7 @@ int pw_port_use_buffers(struct pw_port *port, uint32_t mix_id, struct spa_buffer **buffers, uint32_t n_buffers); /** Allocate memory for buffers on a port \memberof pw_port */ -int pw_port_alloc_buffers(struct pw_port *port, uint32_t mix_id, +int pw_port_alloc_buffers(struct pw_port *port, struct spa_pod **params, uint32_t n_params, struct spa_buffer **buffers, uint32_t *n_buffers);