[PATCH v2 08/10] card: Remove n_sinks and n_sources from pa_card_profile

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

 



Those fields are redundant, because the same information can be
inferred from sink_prototypes and source_prototypes.
---
 src/modules/alsa/module-alsa-card.c             | 4 ----
 src/modules/bluetooth/module-bluetooth-device.c | 8 --------
 src/modules/dbus/iface-card-profile.c           | 8 ++++----
 src/modules/module-switch-on-port-available.c   | 4 ++--
 src/pulsecore/card.c                            | 1 -
 src/pulsecore/card.h                            | 3 ---
 src/pulsecore/protocol-native.c                 | 4 ++--
 7 files changed, 8 insertions(+), 24 deletions(-)

diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
index bcb3b08..9e22696 100644
--- a/src/modules/alsa/module-alsa-card.c
+++ b/src/modules/alsa/module-alsa-card.c
@@ -154,8 +154,6 @@ static void add_profiles(struct userdata *u, pa_card_new_data *data) {
         cp->priority = ap->priority;
 
         if (ap->output_mappings) {
-            cp->n_sinks = pa_idxset_size(ap->output_mappings);
-
             PA_IDXSET_FOREACH(m, ap->output_mappings, idx) {
                 if (!m->sink_prototype)
                     m->sink_prototype = pa_device_prototype_new(PA_DIRECTION_OUTPUT);
@@ -172,8 +170,6 @@ static void add_profiles(struct userdata *u, pa_card_new_data *data) {
         }
 
         if (ap->input_mappings) {
-            cp->n_sources = pa_idxset_size(ap->input_mappings);
-
             PA_IDXSET_FOREACH(m, ap->input_mappings, idx) {
                 if (!m->source_prototype)
                     m->source_prototype = pa_device_prototype_new(PA_DIRECTION_INPUT);
diff --git a/src/modules/bluetooth/module-bluetooth-device.c b/src/modules/bluetooth/module-bluetooth-device.c
index cfa8b8d..f133d56 100644
--- a/src/modules/bluetooth/module-bluetooth-device.c
+++ b/src/modules/bluetooth/module-bluetooth-device.c
@@ -2225,8 +2225,6 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid
         p = pa_card_profile_new("a2dp", _("High Fidelity Playback (A2DP)"), sizeof(enum profile));
         p->priority = 10;
         pa_hashmap_put(p->sink_prototypes, u->sink_prototype, u->sink_prototype);
-        p->n_sinks = 1;
-        p->n_sources = 0;
         p->max_sink_channels = 2;
         p->max_source_channels = 0;
         pa_hashmap_put(output_port->profiles, p->name, p);
@@ -2237,8 +2235,6 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid
         p = pa_card_profile_new("a2dp_source", _("High Fidelity Capture (A2DP)"), sizeof(enum profile));
         p->priority = 10;
         pa_hashmap_put(p->source_prototypes, u->source_prototype, u->source_prototype);
-        p->n_sinks = 0;
-        p->n_sources = 1;
         p->max_sink_channels = 0;
         p->max_source_channels = 2;
         pa_hashmap_put(input_port->profiles, p->name, p);
@@ -2252,8 +2248,6 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid
         if (!USE_SCO_OVER_PCM(u)) {
             pa_hashmap_put(p->sink_prototypes, u->sink_prototype, u->sink_prototype);
             pa_hashmap_put(p->source_prototypes, u->source_prototype, u->source_prototype);
-            p->n_sinks = 1;
-            p->n_sources = 1;
             p->max_sink_channels = 1;
             p->max_source_channels = 1;
         }
@@ -2270,8 +2264,6 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid
         if (!USE_SCO_OVER_PCM(u)) {
             pa_hashmap_put(p->sink_prototypes, u->sink_prototype, u->sink_prototype);
             pa_hashmap_put(p->source_prototypes, u->source_prototype, u->source_prototype);
-            p->n_sinks = 1;
-            p->n_sources = 1;
             p->max_sink_channels = 1;
             p->max_source_channels = 1;
         }
diff --git a/src/modules/dbus/iface-card-profile.c b/src/modules/dbus/iface-card-profile.c
index 2cfac7b..62ed2ae 100644
--- a/src/modules/dbus/iface-card-profile.c
+++ b/src/modules/dbus/iface-card-profile.c
@@ -116,7 +116,7 @@ static void handle_get_sinks(DBusConnection *conn, DBusMessage *msg, void *userd
     pa_assert(msg);
     pa_assert(p);
 
-    sinks = p->profile->n_sinks;
+    sinks = pa_hashmap_size(p->profile->sink_prototypes);
 
     pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_UINT32, &sinks);
 }
@@ -129,7 +129,7 @@ static void handle_get_sources(DBusConnection *conn, DBusMessage *msg, void *use
     pa_assert(msg);
     pa_assert(p);
 
-    sources = p->profile->n_sources;
+    sources = pa_hashmap_size(p->profile->source_prototypes);
 
     pa_dbus_send_basic_variant_reply(conn, msg, DBUS_TYPE_UINT32, &sources);
 }
@@ -160,8 +160,8 @@ static void handle_get_all(DBusConnection *conn, DBusMessage *msg, void *userdat
     pa_assert(msg);
     pa_assert(p);
 
-    sinks = p->profile->n_sinks;
-    sources = p->profile->n_sources;
+    sinks = pa_hashmap_size(p->profile->sink_prototypes);
+    sources = pa_hashmap_size(p->profile->source_prototypes);
     priority = p->profile->priority;
 
     pa_assert_se((reply = dbus_message_new_method_return(msg)));
diff --git a/src/modules/module-switch-on-port-available.c b/src/modules/module-switch-on-port-available.c
index 2ba5397..92730fe 100644
--- a/src/modules/module-switch-on-port-available.c
+++ b/src/modules/module-switch-on-port-available.c
@@ -57,7 +57,7 @@ static bool profile_good_for_output(pa_card_profile *profile) {
 
     pa_assert(profile);
 
-    if (profile->card->active_profile->n_sources != profile->n_sources)
+    if (pa_hashmap_size(profile->card->active_profile->source_prototypes) != pa_hashmap_size(profile->source_prototypes))
         return false;
 
     if (profile->card->active_profile->max_source_channels != profile->max_source_channels)
@@ -78,7 +78,7 @@ static bool profile_good_for_output(pa_card_profile *profile) {
 static bool profile_good_for_input(pa_card_profile *profile) {
     pa_assert(profile);
 
-    if (profile->card->active_profile->n_sinks != profile->n_sinks)
+    if (pa_hashmap_size(profile->card->active_profile->sink_prototypes) != pa_hashmap_size(profile->sink_prototypes))
         return false;
 
     if (profile->card->active_profile->max_sink_channels != profile->max_sink_channels)
diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c
index 3da7c9a..32e1652 100644
--- a/src/pulsecore/card.c
+++ b/src/pulsecore/card.c
@@ -72,7 +72,6 @@ pa_card_profile *pa_card_profile_new(const char *name, const char *description,
     c->priority = 0;
     c->sink_prototypes = pa_hashmap_new(NULL, NULL);
     c->source_prototypes = pa_hashmap_new(NULL, NULL);
-    c->n_sinks = c->n_sources = 0;
     c->max_sink_channels = c->max_source_channels = 0;
     c->available = PA_AVAILABLE_UNKNOWN;
 
diff --git a/src/pulsecore/card.h b/src/pulsecore/card.h
index 2f3dd06..ce1cb22 100644
--- a/src/pulsecore/card.h
+++ b/src/pulsecore/card.h
@@ -71,9 +71,6 @@ typedef struct pa_card_profile {
     pa_hashmap *sink_prototypes; /* pa_device_prototype -> pa_device_prototype (hashmap-as-a-set) */
     pa_hashmap *source_prototypes; /* pa_device_prototype -> pa_device_prototype (hashmap-as-a-set) */
 
-    unsigned n_sinks;
-    unsigned n_sources;
-
     unsigned max_sink_channels;
     unsigned max_source_channels;
 
diff --git a/src/pulsecore/protocol-native.c b/src/pulsecore/protocol-native.c
index dd38cc4..88ebcdc 100644
--- a/src/pulsecore/protocol-native.c
+++ b/src/pulsecore/protocol-native.c
@@ -3289,8 +3289,8 @@ static void card_fill_tagstruct(pa_native_connection *c, pa_tagstruct *t, pa_car
     PA_HASHMAP_FOREACH(p, card->profiles, state) {
         pa_tagstruct_puts(t, p->name);
         pa_tagstruct_puts(t, p->description);
-        pa_tagstruct_putu32(t, p->n_sinks);
-        pa_tagstruct_putu32(t, p->n_sources);
+        pa_tagstruct_putu32(t, pa_hashmap_size(p->sink_prototypes));
+        pa_tagstruct_putu32(t, pa_hashmap_size(p->source_prototypes));
         pa_tagstruct_putu32(t, p->priority);
 
         if (c->version >= 29)
-- 
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