link: also unlink controls

This commit is contained in:
Wim Taymans 2018-09-28 17:49:57 +02:00
parent 857352e4a4
commit 089fc2e8c1

View file

@ -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);