From bfac6f04dbfa2c0ca42314e98683fd587bbc7403 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Wed, 21 Oct 2020 15:27:50 +0200 Subject: [PATCH] policy-node: avoid rescan when moving a node When we are moving a node, the node becomes unlinked temporarily. Make sure the rescan code doesn't try to link it to a node meanwhile. Fixes #344 --- src/examples/media-session/policy-node.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/examples/media-session/policy-node.c b/src/examples/media-session/policy-node.c index 01fba97f3..29abed236 100644 --- a/src/examples/media-session/policy-node.c +++ b/src/examples/media-session/policy-node.c @@ -97,6 +97,7 @@ struct node { unsigned int configured:1; unsigned int dont_remix:1; unsigned int monitor:1; + unsigned int moving:1; }; static bool find_format(struct node *node) @@ -557,6 +558,10 @@ static int rescan_node(struct impl *impl, struct node *n) pw_log_debug(NAME " %p: node %d is not active", impl, n->id); return 0; } + if (n->moving) { + pw_log_debug(NAME " %p: node %d is moving", impl, n->id); + return 0; + } if (n->type == NODE_TYPE_DEVICE) { configure_node(n, NULL, false); @@ -753,8 +758,10 @@ static int move_node(struct impl *impl, uint32_t source, uint32_t target) pw_properties_parse_bool(str)) continue; + n->moving = true; unlink_nodes(n, src_node); link_nodes(n, dst_node); + n->moving = false; } return 0; }