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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx>

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



[Index of Archives]     [Linux Audio Users]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux