From b0068fd46b32f6054cccc2522aed66fa5748bb87 Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 31 May 2021 15:40:26 +0200 Subject: [PATCH] media-session: use direction to find the node by name Also use the stream direction when finding a node by name. We should only select nodes that have the right direction. --- src/examples/media-session/media-session.c | 2 +- src/examples/media-session/policy-node.c | 8 +++++--- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/src/examples/media-session/media-session.c b/src/examples/media-session/media-session.c index 1cc8a957f..d51d6385b 100644 --- a/src/examples/media-session/media-session.c +++ b/src/examples/media-session/media-session.c @@ -1861,7 +1861,7 @@ static int link_nodes(struct impl *impl, struct endpoint_link *link, inport = find_input_port(impl, outnode, outport, innode); if (inport == NULL) { - pw_log_debug(NAME" %p: port %d:%d can't be linked", impl, + pw_log_debug(NAME" %p: port %d:%d can't be linked, no input port", impl, outport->direction, outport->obj.id); continue; } diff --git a/src/examples/media-session/policy-node.c b/src/examples/media-session/policy-node.c index 2e641453a..c996bfd54 100644 --- a/src/examples/media-session/policy-node.c +++ b/src/examples/media-session/policy-node.c @@ -447,7 +447,7 @@ static const char *get_device_name(struct node *node) return pw_properties_get(node->obj->obj.props, PW_KEY_NODE_NAME); } -static uint32_t find_device_for_name(struct impl *impl, const char *name) +static uint32_t find_device_for_name(struct impl *impl, const char *name, enum spa_direction direction) { struct node *node; const char *str; @@ -458,6 +458,8 @@ static uint32_t find_device_for_name(struct impl *impl, const char *name) return id; if ((str = get_device_name(node)) == NULL) continue; + if (node->direction == direction) + continue; if (spa_streq(str, name)) return node->obj->obj.id; } @@ -798,9 +800,9 @@ static int rescan_node(struct impl *impl, struct node *n) /* we always honour the target node asked for by the client */ path_id = SPA_ID_INVALID; if ((str = spa_dict_lookup(props, PW_KEY_NODE_TARGET)) != NULL) - path_id = find_device_for_name(impl, str); + path_id = find_device_for_name(impl, str, n->direction); if (path_id == SPA_ID_INVALID && n->obj->target_node != NULL) - path_id = find_device_for_name(impl, n->obj->target_node); + path_id = find_device_for_name(impl, n->obj->target_node, n->direction); pw_log_info("trying to link node %d exclusive:%d reconnect:%d target:%d follows-default:%d", n->id, exclusive, reconnect, path_id, follows_default);