From a0777d78062405e606aa9d79e9caf0fac91a8fdf Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 7 Aug 2020 10:50:30 +0200 Subject: policy-node: only set peer when we actually linked something --- src/examples/media-session/media-session.c | 4 +++- src/examples/media-session/policy-node.c | 5 ++--- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/examples/media-session/media-session.c b/src/examples/media-session/media-session.c index 71d70d75..fded24ee 100644 --- a/src/examples/media-session/media-session.c +++ b/src/examples/media-session/media-session.c @@ -1549,6 +1549,7 @@ static int link_nodes(struct impl *impl, struct endpoint_link *link, { struct pw_properties *props; struct sm_port *outport, *inport; + int count = 0; pw_log_debug(NAME" %p: linking %d -> %d", impl, outnode->obj.id, innode->obj.id); @@ -1596,6 +1597,7 @@ static int link_nodes(struct impl *impl, struct endpoint_link *link, l->input_node = innode->obj.id; l->input_port = inport->obj.id; pw_proxy_add_listener(p, &l->listener, &proxy_link_events, l); + count++; if (link) { l->endpoint_link = link; @@ -1606,7 +1608,7 @@ static int link_nodes(struct impl *impl, struct endpoint_link *link, } pw_properties_free(props); - return 0; + return count; } diff --git a/src/examples/media-session/policy-node.c b/src/examples/media-session/policy-node.c index 9d6e2568..dcf96970 100644 --- a/src/examples/media-session/policy-node.c +++ b/src/examples/media-session/policy-node.c @@ -466,8 +466,6 @@ static int link_nodes(struct node *node, struct node *peer) #endif } - node->peer = peer; - if (node->direction == PW_DIRECTION_INPUT) { output = peer; input = node; @@ -480,7 +478,8 @@ static int link_nodes(struct node *node, struct node *peer) pw_properties_setf(props, PW_KEY_LINK_INPUT_NODE, "%d", input->id); pw_log_info("linking node %d to node %d", output->id, input->id); - sm_media_session_create_links(impl->session, &props->dict); + if (sm_media_session_create_links(impl->session, &props->dict) > 0) + node->peer = peer; pw_properties_free(props); -- cgit v1.2.3