if (best_profile && best_profile->priority >= profile->priority)
continue;
+ if (!card->active_profile) {
+ best_profile = profile;
+ continue;
+ }
+
/* We make a best effort to keep other direction unchanged */
- if (card->active_profile && !port->is_input) {
+ if (!port->is_input) {
if (card->active_profile->n_sources != profile->n_sources)
continue;
continue;
}
- if (card->active_profile && !port->is_output) {
+ if (!port->is_output) {
if (card->active_profile->n_sinks != profile->n_sinks)
continue;
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;
}