]> code.delx.au - pulseaudio/commitdiff
card: Ensure we still pick a profile even if it's unavailable.
authorColin Guthrie <colin@mageia.org>
Fri, 15 Nov 2013 08:33:37 +0000 (09:33 +0100)
committerTanu Kaskinen <tanu.kaskinen@linux.intel.com>
Fri, 22 Nov 2013 09:30:33 +0000 (11:30 +0200)
f434087e42b introduced the potential to not select a card profile if
all the profiles were marked as unavailable.

While this is very unlikely, it's a theoretical posibility, so if the
initial choice of a profile fails, try harder.

src/pulsecore/card.c

index 4ae16c2f33cc3fcf69b3aa24b7fc56c65b94d57d..03c0bb61efbd726e5106e9f14b240c61ef4e2fb1 100644 (file)
@@ -202,6 +202,12 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
             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 (!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);
     }