mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-12-16 08:56:45 -05:00
acp: improve port and profile index select
Keep 3 options, the available ports, unknown and highest priority other ports.
This commit is contained in:
parent
5f38562d38
commit
6e339200af
1 changed files with 26 additions and 12 deletions
|
|
@ -622,9 +622,11 @@ static void init_eld_ctls(pa_card *impl)
|
||||||
uint32_t acp_card_find_best_profile_index(struct acp_card *card, const char *name)
|
uint32_t acp_card_find_best_profile_index(struct acp_card *card, const char *name)
|
||||||
{
|
{
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
uint32_t best_alt = ACP_INVALID_INDEX, best = ACP_INVALID_INDEX;
|
uint32_t best, best2, best3;
|
||||||
struct acp_card_profile **profiles = card->profiles;
|
struct acp_card_profile **profiles = card->profiles;
|
||||||
|
|
||||||
|
best = best2 = best3 = ACP_INVALID_INDEX;
|
||||||
|
|
||||||
for (i = 0; i < card->n_profiles; i++) {
|
for (i = 0; i < card->n_profiles; i++) {
|
||||||
struct acp_card_profile *p = profiles[i];
|
struct acp_card_profile *p = profiles[i];
|
||||||
|
|
||||||
|
|
@ -633,16 +635,21 @@ uint32_t acp_card_find_best_profile_index(struct acp_card *card, const char *nam
|
||||||
best = i;
|
best = i;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (p->available != ACP_AVAILABLE_NO) {
|
if (p->available == ACP_AVAILABLE_YES) {
|
||||||
if (best == ACP_INVALID_INDEX || p->priority > profiles[best]->priority)
|
if (best == ACP_INVALID_INDEX || p->priority > profiles[best]->priority)
|
||||||
best = i;
|
best = i;
|
||||||
|
} else if (p->available != ACP_AVAILABLE_NO) {
|
||||||
|
if (best2 == ACP_INVALID_INDEX || p->priority > profiles[best2]->priority)
|
||||||
|
best2 = i;
|
||||||
} else {
|
} else {
|
||||||
if (best_alt == ACP_INVALID_INDEX || p->priority > profiles[best_alt]->priority)
|
if (best3 == ACP_INVALID_INDEX || p->priority > profiles[best3]->priority)
|
||||||
best_alt = i;
|
best3 = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (best == ACP_INVALID_INDEX)
|
if (best == ACP_INVALID_INDEX)
|
||||||
best = best_alt;
|
best = best2;
|
||||||
|
if (best == ACP_INVALID_INDEX)
|
||||||
|
best = best3;
|
||||||
if (best == ACP_INVALID_INDEX)
|
if (best == ACP_INVALID_INDEX)
|
||||||
best = 0;
|
best = 0;
|
||||||
return best;
|
return best;
|
||||||
|
|
@ -988,7 +995,7 @@ static int device_enable(pa_card *impl, pa_alsa_mapping *mapping, pa_alsa_device
|
||||||
|
|
||||||
port_index = acp_device_find_best_port_index(&dev->device, NULL);
|
port_index = acp_device_find_best_port_index(&dev->device, NULL);
|
||||||
|
|
||||||
dev->active_port = (pa_device_port*)dev->device.ports[port_index];
|
dev->active_port = (pa_device_port*)impl->card.ports[port_index];
|
||||||
if (dev->active_port)
|
if (dev->active_port)
|
||||||
dev->active_port->port.flags |= ACP_PORT_ACTIVE;
|
dev->active_port->port.flags |= ACP_PORT_ACTIVE;
|
||||||
|
|
||||||
|
|
@ -1295,9 +1302,11 @@ static void sync_mixer(pa_alsa_device *d, pa_device_port *port)
|
||||||
uint32_t acp_device_find_best_port_index(struct acp_device *dev, const char *name)
|
uint32_t acp_device_find_best_port_index(struct acp_device *dev, const char *name)
|
||||||
{
|
{
|
||||||
uint32_t i;
|
uint32_t i;
|
||||||
uint32_t best_alt = ACP_INVALID_INDEX, best = ACP_INVALID_INDEX;
|
uint32_t best, best2, best3;
|
||||||
struct acp_port **ports = dev->ports;
|
struct acp_port **ports = dev->ports;
|
||||||
|
|
||||||
|
best = best2 = best3 = ACP_INVALID_INDEX;
|
||||||
|
|
||||||
for (i = 0; i < dev->n_ports; i++) {
|
for (i = 0; i < dev->n_ports; i++) {
|
||||||
struct acp_port *p = ports[i];
|
struct acp_port *p = ports[i];
|
||||||
|
|
||||||
|
|
@ -1306,19 +1315,24 @@ uint32_t acp_device_find_best_port_index(struct acp_device *dev, const char *nam
|
||||||
best = i;
|
best = i;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (p->available != ACP_AVAILABLE_NO) {
|
if (p->available == ACP_AVAILABLE_YES) {
|
||||||
if (best == ACP_INVALID_INDEX || p->priority > ports[best]->priority)
|
if (best == ACP_INVALID_INDEX || p->priority > ports[best]->priority)
|
||||||
best = i;
|
best = i;
|
||||||
|
} else if (p->available != ACP_AVAILABLE_NO) {
|
||||||
|
if (best2 == ACP_INVALID_INDEX || p->priority > ports[best2]->priority)
|
||||||
|
best2 = i;
|
||||||
} else {
|
} else {
|
||||||
if (best_alt == ACP_INVALID_INDEX || p->priority > ports[best_alt]->priority)
|
if (best3 == ACP_INVALID_INDEX || p->priority > ports[best3]->priority)
|
||||||
best_alt = i;
|
best3 = i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (best == ACP_INVALID_INDEX)
|
if (best == ACP_INVALID_INDEX)
|
||||||
best = best_alt;
|
best = best2;
|
||||||
|
if (best == ACP_INVALID_INDEX)
|
||||||
|
best = best3;
|
||||||
if (best == ACP_INVALID_INDEX)
|
if (best == ACP_INVALID_INDEX)
|
||||||
best = 0;
|
best = 0;
|
||||||
return best;
|
return ports[best]->index;
|
||||||
}
|
}
|
||||||
|
|
||||||
int acp_device_set_port(struct acp_device *dev, uint32_t port_index)
|
int acp_device_set_port(struct acp_device *dev, uint32_t port_index)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue