mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-10-29 05:40:23 -04:00
Assume that the profiles hashmap of ports is always non-NULL.
It's a valid assumption nowadays, because the hashmap is created in pa_device_port_new().
This commit is contained in:
parent
12af302ac7
commit
d184b54d7c
2 changed files with 44 additions and 46 deletions
|
|
@ -55,47 +55,47 @@ static pa_bool_t try_to_switch_profile(pa_card *card, pa_device_port *port) {
|
|||
|
||||
pa_log_debug("Finding best profile");
|
||||
|
||||
if (port->profiles)
|
||||
PA_HASHMAP_FOREACH(profile, port->profiles, state) {
|
||||
if (best_profile && best_profile->priority >= profile->priority)
|
||||
PA_HASHMAP_FOREACH(profile, port->profiles, state) {
|
||||
if (best_profile && best_profile->priority >= profile->priority)
|
||||
continue;
|
||||
|
||||
/* We make a best effort to keep other direction unchanged */
|
||||
if (!port->is_input) {
|
||||
if (card->active_profile->n_sources != profile->n_sources)
|
||||
continue;
|
||||
|
||||
|
||||
/* We make a best effort to keep other direction unchanged */
|
||||
if (!port->is_input) {
|
||||
if (card->active_profile->n_sources != profile->n_sources)
|
||||
continue;
|
||||
|
||||
if (card->active_profile->max_source_channels != profile->max_source_channels)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!port->is_output) {
|
||||
if (card->active_profile->n_sinks != profile->n_sinks)
|
||||
continue;
|
||||
|
||||
if (card->active_profile->max_sink_channels != profile->max_sink_channels)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (port->is_output) {
|
||||
/* Try not to switch to HDMI sinks from analog when HDMI is becoming available */
|
||||
uint32_t state2;
|
||||
pa_sink *sink;
|
||||
pa_bool_t found_active_port = FALSE;
|
||||
PA_IDXSET_FOREACH(sink, card->sinks, state2) {
|
||||
if (!sink->active_port)
|
||||
continue;
|
||||
if (sink->active_port->available != PA_PORT_AVAILABLE_NO)
|
||||
found_active_port = TRUE;
|
||||
}
|
||||
if (found_active_port)
|
||||
continue;
|
||||
}
|
||||
|
||||
best_profile = profile;
|
||||
if (card->active_profile->max_source_channels != profile->max_source_channels)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!port->is_output) {
|
||||
if (card->active_profile->n_sinks != profile->n_sinks)
|
||||
continue;
|
||||
|
||||
if (card->active_profile->max_sink_channels != profile->max_sink_channels)
|
||||
continue;
|
||||
}
|
||||
|
||||
if (port->is_output) {
|
||||
/* Try not to switch to HDMI sinks from analog when HDMI is becoming available */
|
||||
uint32_t state2;
|
||||
pa_sink *sink;
|
||||
pa_bool_t found_active_port = FALSE;
|
||||
|
||||
PA_IDXSET_FOREACH(sink, card->sinks, state2) {
|
||||
if (!sink->active_port)
|
||||
continue;
|
||||
if (sink->active_port->available != PA_PORT_AVAILABLE_NO)
|
||||
found_active_port = TRUE;
|
||||
}
|
||||
|
||||
if (found_active_port)
|
||||
continue;
|
||||
}
|
||||
|
||||
best_profile = profile;
|
||||
}
|
||||
|
||||
if (!best_profile) {
|
||||
pa_log_debug("No suitable profile found");
|
||||
return FALSE;
|
||||
|
|
@ -152,8 +152,7 @@ static pa_hook_result_t port_available_hook_callback(pa_core *c, pa_device_port
|
|||
|
||||
find_sink_and_source(card, port, &sink, &source);
|
||||
|
||||
is_active_profile = port->profiles &&
|
||||
card->active_profile == pa_hashmap_get(port->profiles, card->active_profile->name);
|
||||
is_active_profile = card->active_profile == pa_hashmap_get(port->profiles, card->active_profile->name);
|
||||
is_active_port = (sink && sink->active_port == port) || (source && source->active_port == port);
|
||||
|
||||
if (port->available == PA_PORT_AVAILABLE_NO && !is_active_port)
|
||||
|
|
|
|||
|
|
@ -3261,6 +3261,8 @@ static void card_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_car
|
|||
pa_tagstruct_putu32(t, pa_hashmap_size(card->ports));
|
||||
|
||||
PA_HASHMAP_FOREACH(port, card->ports, state) {
|
||||
void *state2;
|
||||
|
||||
pa_tagstruct_puts(t, port->name);
|
||||
pa_tagstruct_puts(t, port->description);
|
||||
pa_tagstruct_putu32(t, port->priority);
|
||||
|
|
@ -3268,13 +3270,10 @@ static void card_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_car
|
|||
pa_tagstruct_putu8(t, /* FIXME: port->direction */ (port->is_input ? PA_DIRECTION_INPUT : 0) | (port->is_output ? PA_DIRECTION_OUTPUT : 0));
|
||||
pa_tagstruct_put_proplist(t, port->proplist);
|
||||
|
||||
if (port->profiles) {
|
||||
void* state2;
|
||||
pa_tagstruct_putu32(t, pa_hashmap_size(port->profiles));
|
||||
PA_HASHMAP_FOREACH(p, port->profiles, state2)
|
||||
pa_tagstruct_puts(t, p->name);
|
||||
} else
|
||||
pa_tagstruct_putu32(t, 0);
|
||||
pa_tagstruct_putu32(t, pa_hashmap_size(port->profiles));
|
||||
|
||||
PA_HASHMAP_FOREACH(p, port->profiles, state2)
|
||||
pa_tagstruct_puts(t, p->name);
|
||||
}
|
||||
|
||||
} else
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue