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.
This commit is contained in:
Wim Taymans 2021-05-31 15:40:26 +02:00
parent d37ea7851a
commit b0068fd46b
2 changed files with 6 additions and 4 deletions

View file

@ -1861,7 +1861,7 @@ static int link_nodes(struct impl *impl, struct endpoint_link *link,
inport = find_input_port(impl, outnode, outport, innode); inport = find_input_port(impl, outnode, outport, innode);
if (inport == NULL) { 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); outport->direction, outport->obj.id);
continue; continue;
} }

View file

@ -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); 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; struct node *node;
const char *str; const char *str;
@ -458,6 +458,8 @@ static uint32_t find_device_for_name(struct impl *impl, const char *name)
return id; return id;
if ((str = get_device_name(node)) == NULL) if ((str = get_device_name(node)) == NULL)
continue; continue;
if (node->direction == direction)
continue;
if (spa_streq(str, name)) if (spa_streq(str, name))
return node->obj->obj.id; 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 */ /* we always honour the target node asked for by the client */
path_id = SPA_ID_INVALID; path_id = SPA_ID_INVALID;
if ((str = spa_dict_lookup(props, PW_KEY_NODE_TARGET)) != NULL) 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) 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, 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); exclusive, reconnect, path_id, follows_default);