mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
policy-node: boost priority on default device
When we find a default device, boost the priority so that it remains the target device even when a device with higher priority is scanned later. Fixes issue where default device was not selected because a higher priority device was encountered after it.
This commit is contained in:
parent
3e56161ee2
commit
4a8afe389c
1 changed files with 7 additions and 5 deletions
|
|
@ -359,7 +359,6 @@ static int find_node(void *data, struct node *node)
|
|||
int priority = 0;
|
||||
uint64_t plugged = 0;
|
||||
struct sm_device *device = node->obj->device;
|
||||
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);
|
||||
|
|
@ -380,16 +379,19 @@ static int find_node(void *data, struct node *node)
|
|||
pw_log_debug(".. incompatible media %s <-> %s", node->media, find->target->media);
|
||||
return 0;
|
||||
}
|
||||
plugged = node->plugged;
|
||||
priority = node->priority;
|
||||
|
||||
if (node->media && strcmp(node->media, "Audio") == 0) {
|
||||
bool is_default = false;
|
||||
if (node->direction == PW_DIRECTION_INPUT)
|
||||
is_default = impl->default_audio_sink == node->id;
|
||||
else if (node->direction == PW_DIRECTION_OUTPUT)
|
||||
is_default = impl->default_audio_source == node->id;
|
||||
if (is_default)
|
||||
priority += 1000;
|
||||
}
|
||||
|
||||
plugged = node->plugged;
|
||||
priority = node->priority;
|
||||
|
||||
if ((find->exclusive && node->obj->info->state == PW_NODE_STATE_RUNNING) ||
|
||||
(node->peer && node->peer->exclusive)) {
|
||||
pw_log_debug(NAME " %p: node '%d' in use", impl, node->id);
|
||||
|
|
@ -399,7 +401,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 || is_default ||
|
||||
if (find->node == NULL ||
|
||||
priority > find->priority ||
|
||||
(priority == find->priority && plugged > find->plugged)) {
|
||||
pw_log_debug(NAME " %p: new best %d %" PRIu64, impl, priority, plugged);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue