[pulseaudio-discuss] [RFC 1/2] card: Rank profiles based on available flag

Luiz Augusto von Dentz luiz.dentz at gmail.com
Tue Nov 12 03:02:43 PST 2013


From: Luiz Augusto von Dentz <luiz.von.dentz at intel.com>

This makes pa_card_new to rank profiles based on their available flag and
only consider their priority in case they have the same rank.
---
 src/pulsecore/card.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c
index 4ae16c2..2573049 100644
--- a/src/pulsecore/card.c
+++ b/src/pulsecore/card.c
@@ -196,13 +196,20 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
 
     if (!c->active_profile) {
         PA_HASHMAP_FOREACH(profile, c->profiles, state) {
-            if (profile->available == PA_AVAILABLE_NO)
+            if (!c->active_profile) {
+                c->active_profile = profile;
+                continue;
+            }
+
+            if (profile->available > c->active_profile->available) {
+                c->active_profile = profile;
                 continue;
+            }
 
-            if (!c->active_profile || profile->priority > c->active_profile->priority)
+            if (profile->available == c->active_profile->available &&
+                profile->priority > c->active_profile->priority)
                 c->active_profile = profile;
         }
-        pa_assert(c->active_profile);
     }
 
     c->userdata = NULL;
-- 
1.8.3.1



More information about the pulseaudio-discuss mailing list