diff --git a/src/pipewire/link.c b/src/pipewire/link.c index 2aaeb9f91..6a0ce31a9 100644 --- a/src/pipewire/link.c +++ b/src/pipewire/link.c @@ -1255,6 +1255,26 @@ static void try_link_controls(struct impl *impl, struct pw_port *port, struct pw } } +static void try_unlink_controls(struct impl *impl, struct pw_port *port, struct pw_port *target) +{ + struct pw_control *cin, *cout; + int res; + + pw_log_debug("link %p: unlinking controls", impl); + spa_list_for_each(cout, &port->control_list[SPA_DIRECTION_OUTPUT], port_link) { + spa_list_for_each(cin, &target->control_list[SPA_DIRECTION_INPUT], port_link) { + if ((res = pw_control_unlink(cout, cin)) < 0) + pw_log_error("failed to unlink controls: %s", spa_strerror(res)); + } + } + spa_list_for_each(cin, &port->control_list[SPA_DIRECTION_INPUT], port_link) { + spa_list_for_each(cout, &target->control_list[SPA_DIRECTION_OUTPUT], port_link) { + if ((res = pw_control_unlink(cout, cin)) < 0) + pw_log_error("failed to unlink controls: %s", spa_strerror(res)); + } + } +} + struct pw_link *pw_link_new(struct pw_core *core, struct pw_port *output, struct pw_port *input, @@ -1437,6 +1457,8 @@ void pw_link_destroy(struct pw_link *link) if (link->registered) spa_list_remove(&link->link); + try_unlink_controls(impl, link->input, link->output); + input_remove(link, link->input); output_remove(link, link->output);