diff --git a/src/pipewire/link.c b/src/pipewire/link.c index 718bd9f52..7079cc8d0 100644 --- a/src/pipewire/link.c +++ b/src/pipewire/link.c @@ -874,6 +874,8 @@ static void input_remove(struct pw_link *this, struct pw_port *port) pw_loop_invoke(port->node->data_loop, do_remove_input, 1, NULL, 0, true, this); + pw_map_remove(&port->mix_port_map, this->rt.in_port.port_id); + spa_list_remove(&this->input_link); spa_hook_list_call(&this->input->listener_list, struct pw_port_events, link_removed, this); @@ -901,6 +903,8 @@ static void output_remove(struct pw_link *this, struct pw_port *port) pw_loop_invoke(port->node->data_loop, do_remove_output, 1, NULL, 0, true, this); + pw_map_remove(&port->mix_port_map, this->rt.out_port.port_id); + spa_list_remove(&this->output_link); spa_hook_list_call(&this->output->listener_list, struct pw_port_events, link_removed, this); @@ -1141,9 +1145,6 @@ struct pw_link *pw_link_new(struct pw_core *core, pw_port_add_listener(output, &impl->output_port_listener, &output_port_events, impl); pw_node_add_listener(output_node, &impl->output_node_listener, &output_node_events, impl); - pw_log_debug("link %p: constructed %p:%d -> %p:%d", impl, - output_node, output->port_id, input_node, input->port_id); - input_node->live = output_node->live; if (output_node->clock) input_node->clock = output_node->clock; @@ -1163,6 +1164,13 @@ struct pw_link *pw_link_new(struct pw_core *core, this->io = SPA_IO_BUFFERS_INIT; + this->rt.out_port.port_id = pw_map_insert_new(&output->mix_port_map, NULL); + this->rt.in_port.port_id = pw_map_insert_new(&input->mix_port_map, NULL); + + pw_log_debug("link %p: constructed %p:%d.%d -> %p:%d.%d", impl, + output_node, output->port_id, this->rt.out_port.port_id, + input_node, input->port_id, this->rt.in_port.port_id); + spa_graph_port_init(&this->rt.out_port, PW_DIRECTION_OUTPUT, this->rt.out_port.port_id, diff --git a/src/pipewire/port.c b/src/pipewire/port.c index 0c4f786f4..79badaa03 100644 --- a/src/pipewire/port.c +++ b/src/pipewire/port.c @@ -211,6 +211,7 @@ struct pw_port *pw_port_new(enum pw_direction direction, schedule_mix_node : schedule_tee_node; spa_graph_node_set_implementation(&this->rt.mix_node, &this->mix_node); + pw_map_init(&this->mix_port_map, 64, 64); spa_graph_port_init(&this->rt.mix_port, pw_direction_reverse(this->direction), @@ -558,6 +559,8 @@ void pw_port_destroy(struct pw_port *port) free_allocation(&port->allocation); + pw_map_clear(&port->mix_port_map); + if (port->properties) pw_properties_free(port->properties); diff --git a/src/pipewire/private.h b/src/pipewire/private.h index 3aad48fd8..47510fdd5 100644 --- a/src/pipewire/private.h +++ b/src/pipewire/private.h @@ -334,6 +334,7 @@ struct pw_port { struct spa_node *mix; /**< optional port buffer mix/split */ struct spa_node mix_node; /**< mix node implementation */ + struct pw_map mix_port_map; /**< map from port_id from mixer */ struct { struct spa_graph *graph;