Then fall back to the unknown ones, and only then pick one we know to be unavailable as a last resort. --- src/pulsecore/card.c | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c index 03c0bb6..71883cc 100644 --- a/src/pulsecore/card.c +++ b/src/pulsecore/card.c @@ -195,18 +195,30 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) { c->save_profile = data->save_profile; if (!c->active_profile) { + /* Try hard to pick an available profile, first */ PA_HASHMAP_FOREACH(profile, c->profiles, state) { - if (profile->available == PA_AVAILABLE_NO) + if (profile->available != PA_AVAILABLE_YES) continue; if (!c->active_profile || profile->priority > c->active_profile->priority) c->active_profile = profile; } - /* If all profiles are not available, then we still need to pick one */ + /* If we don't have any available profiles, try the unknown ones... */ if (!c->active_profile) { - PA_HASHMAP_FOREACH(profile, c->profiles, state) + PA_HASHMAP_FOREACH(profile, c->profiles, state) { + if (profile->available != PA_AVAILABLE_UNKNOWN) + continue; + if (!c->active_profile || profile->priority > c->active_profile->priority) c->active_profile = profile; + } + + /* OK, if we can't find one in a good state of availability, just pick any profile */ + if (!c->active_profile) { + PA_HASHMAP_FOREACH(profile, c->profiles, state) + if (!c->active_profile || profile->priority > c->active_profile->priority) + c->active_profile = profile; + } } pa_assert(c->active_profile); } -- 1.8.4.3