]> code.delx.au - pulseaudio/commitdiff
Assume that the profiles hashmap of ports is always non-NULL.
authorTanu Kaskinen <tanuk@iki.fi>
Fri, 8 Jun 2012 18:49:11 +0000 (21:49 +0300)
committerTanu Kaskinen <tanuk@iki.fi>
Fri, 29 Jun 2012 11:24:43 +0000 (14:24 +0300)
It's a valid assumption nowadays, because the hashmap is
created in pa_device_port_new().

src/modules/module-switch-on-port-available.c
src/pulsecore/protocol-native.c

index 5788825770326b9cd68784dbba7a7f9611a40c6e..4c3d4afa75cb81b55f5318c6b86c167a4179bf16 100644 (file)
@@ -55,47 +55,47 @@ static pa_bool_t try_to_switch_profile(pa_card *card, pa_device_port *port) {
 
     pa_log_debug("Finding best profile");
 
-    if (port->profiles)
-        PA_HASHMAP_FOREACH(profile, port->profiles, state) {
-            if (best_profile && best_profile->priority >= profile->priority)
-                continue;
+    PA_HASHMAP_FOREACH(profile, port->profiles, state) {
+        if (best_profile && best_profile->priority >= profile->priority)
+            continue;
 
+        /* We make a best effort to keep other direction unchanged */
+        if (!port->is_input) {
+            if (card->active_profile->n_sources != profile->n_sources)
+                continue;
 
-            /* We make a best effort to keep other direction unchanged */
-            if (!port->is_input) {
-                if (card->active_profile->n_sources != profile->n_sources)
-                    continue;
+            if (card->active_profile->max_source_channels != profile->max_source_channels)
+                continue;
+        }
 
-                if (card->active_profile->max_source_channels != profile->max_source_channels)
-                    continue;
-            }
+        if (!port->is_output) {
+            if (card->active_profile->n_sinks != profile->n_sinks)
+                continue;
 
-            if (!port->is_output) {
-                if (card->active_profile->n_sinks != profile->n_sinks)
-                    continue;
+            if (card->active_profile->max_sink_channels != profile->max_sink_channels)
+                continue;
+        }
 
-                if (card->active_profile->max_sink_channels != profile->max_sink_channels)
-                    continue;
-            }
+        if (port->is_output) {
+            /* Try not to switch to HDMI sinks from analog when HDMI is becoming available */
+            uint32_t state2;
+            pa_sink *sink;
+            pa_bool_t found_active_port = FALSE;
 
-            if (port->is_output) {
-                /* Try not to switch to HDMI sinks from analog when HDMI is becoming available */
-                uint32_t state2;
-                pa_sink *sink;
-                pa_bool_t found_active_port = FALSE;
-                PA_IDXSET_FOREACH(sink, card->sinks, state2) {
-                    if (!sink->active_port)
-                        continue;
-                    if (sink->active_port->available != PA_PORT_AVAILABLE_NO)
-                        found_active_port = TRUE;
-                }
-                if (found_active_port)
+            PA_IDXSET_FOREACH(sink, card->sinks, state2) {
+                if (!sink->active_port)
                     continue;
+                if (sink->active_port->available != PA_PORT_AVAILABLE_NO)
+                    found_active_port = TRUE;
             }
 
-            best_profile = profile;
+            if (found_active_port)
+                continue;
         }
 
+        best_profile = profile;
+    }
+
     if (!best_profile) {
         pa_log_debug("No suitable profile found");
         return FALSE;
@@ -152,8 +152,7 @@ static pa_hook_result_t port_available_hook_callback(pa_core *c, pa_device_port
 
     find_sink_and_source(card, port, &sink, &source);
 
-    is_active_profile = port->profiles &&
-        card->active_profile == pa_hashmap_get(port->profiles, card->active_profile->name);
+    is_active_profile = card->active_profile == pa_hashmap_get(port->profiles, card->active_profile->name);
     is_active_port = (sink && sink->active_port == port) || (source && source->active_port == port);
 
     if (port->available == PA_PORT_AVAILABLE_NO && !is_active_port)
index cb322ccd2ef7c3cd3837354fd7377cc1d003f0ec..bb61f75d7a5e451d8086058cf7d0b22948570d6e 100644 (file)
@@ -3261,6 +3261,8 @@ static void card_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_car
         pa_tagstruct_putu32(t, pa_hashmap_size(card->ports));
 
         PA_HASHMAP_FOREACH(port, card->ports, state) {
+            void *state2;
+
             pa_tagstruct_puts(t, port->name);
             pa_tagstruct_puts(t, port->description);
             pa_tagstruct_putu32(t, port->priority);
@@ -3268,13 +3270,10 @@ static void card_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_car
             pa_tagstruct_putu8(t, /* FIXME: port->direction */ (port->is_input ? PA_DIRECTION_INPUT : 0) | (port->is_output ? PA_DIRECTION_OUTPUT : 0));
             pa_tagstruct_put_proplist(t, port->proplist);
 
-            if (port->profiles) {
-                void* state2;
-                pa_tagstruct_putu32(t, pa_hashmap_size(port->profiles));
-                PA_HASHMAP_FOREACH(p, port->profiles, state2)
-                    pa_tagstruct_puts(t, p->name);
-            } else
-                pa_tagstruct_putu32(t, 0);
+            pa_tagstruct_putu32(t, pa_hashmap_size(port->profiles));
+
+            PA_HASHMAP_FOREACH(p, port->profiles, state2)
+                pa_tagstruct_puts(t, p->name);
         }
 
     } else