]> code.delx.au - pulseaudio/commitdiff
card: Only set active_profile with available profile
authorLuiz Augusto von Dentz <luiz.von.dentz@intel.com>
Sun, 3 Nov 2013 13:05:34 +0000 (15:05 +0200)
committerTanu Kaskinen <tanu.kaskinen@linux.intel.com>
Tue, 5 Nov 2013 19:33:04 +0000 (21:33 +0200)
When a card is being created and no profile has been assigned
pa_card_new will attempt to select one from the list but it does that
without checking the available flag which can lead to select profiles
not available.

src/pulsecore/card.c

index e6e08364b4631912e3513f03e1dbba8b50dd2e23..4ae16c2f33cc3fcf69b3aa24b7fc56c65b94d57d 100644 (file)
@@ -195,9 +195,14 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
             c->save_profile = data->save_profile;
 
     if (!c->active_profile) {
-        PA_HASHMAP_FOREACH(profile, c->profiles, state)
+        PA_HASHMAP_FOREACH(profile, c->profiles, state) {
+            if (profile->available == PA_AVAILABLE_NO)
+                continue;
+
             if (!c->active_profile || profile->priority > c->active_profile->priority)
                 c->active_profile = profile;
+        }
+        pa_assert(c->active_profile);
     }
 
     c->userdata = NULL;