mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-02 09:01:50 -05:00
policy-node: route to the default sink/source when found
This commit is contained in:
parent
61e2d5cb54
commit
02be602f97
1 changed files with 13 additions and 5 deletions
|
|
@ -347,6 +347,8 @@ static int find_node(void *data, struct node *node)
|
|||
int priority = 0;
|
||||
uint64_t plugged = 0;
|
||||
struct sm_device *device = node->obj->device;
|
||||
const char *name;
|
||||
bool is_default = false;
|
||||
|
||||
pw_log_debug(NAME " %p: looking at node '%d' enabled:%d state:%d peer:%p exclusive:%d",
|
||||
impl, node->id, node->enabled, node->obj->info->state, node->peer, node->exclusive);
|
||||
|
|
@ -367,6 +369,16 @@ static int find_node(void *data, struct node *node)
|
|||
pw_log_debug(".. incompatible media %s <-> %s", node->media, find->target->media);
|
||||
return 0;
|
||||
}
|
||||
if ((name = pw_properties_get(node->obj->obj.props, PW_KEY_NODE_NAME)) != NULL) {
|
||||
if (node->media && strcmp(node->media, "Audio") == 0) {
|
||||
if (node->direction == PW_DIRECTION_INPUT &&
|
||||
impl->default_audio_sink != NULL)
|
||||
is_default = strcmp(impl->default_audio_sink, name) == 0;
|
||||
else if (node->direction == PW_DIRECTION_OUTPUT &&
|
||||
impl->default_audio_source != NULL)
|
||||
is_default = strcmp(impl->default_audio_source, name) == 0;
|
||||
}
|
||||
}
|
||||
|
||||
plugged = node->plugged;
|
||||
priority = node->priority;
|
||||
|
|
@ -380,7 +392,7 @@ static int find_node(void *data, struct node *node)
|
|||
pw_log_debug(NAME " %p: found node '%d' %"PRIu64" prio:%d", impl,
|
||||
node->id, plugged, priority);
|
||||
|
||||
if (find->node == NULL ||
|
||||
if (find->node == NULL || is_default ||
|
||||
priority > find->priority ||
|
||||
(priority == find->priority && plugged > find->plugged)) {
|
||||
pw_log_debug(NAME " %p: new best %d %" PRIu64, impl, priority, plugged);
|
||||
|
|
@ -640,13 +652,9 @@ static int move_node(struct impl *impl, const char *source, const char *target)
|
|||
spa_list_for_each(n, &impl->node_list, link) {
|
||||
struct pw_node_info *info;
|
||||
|
||||
pw_log_info("linked %d -> %d", n->obj->obj.id,
|
||||
n->peer ? n->peer->obj->obj.id : SPA_ID_INVALID);
|
||||
|
||||
if (n->peer != src_node)
|
||||
continue;
|
||||
|
||||
pw_log_info("linked %d", n->obj->obj.id);
|
||||
if ((info = n->obj->info) == NULL)
|
||||
continue;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue