]> code.delx.au - pulseaudio/commitdiff
bluetooth: Fix missing port->profile association
authorMikel Astiz <mikel.astiz@bmw-carit.de>
Mon, 20 May 2013 09:48:33 +0000 (11:48 +0200)
committerDavid Henningsson <david.henningsson@canonical.com>
Tue, 21 May 2013 12:46:38 +0000 (14:46 +0200)
Commit 17b3cb954b179392e80b0a46d8f2ba4693aec386 merged Bluetooth ports
into two ports (one for input, one for output) but the association
between ports and profiles was lost.

BugLink: https://bugs.freedesktop.org/show_bug.cgi?id=64713
src/modules/bluetooth/module-bluetooth-device.c

index 47bed2ff1fb57ee44e4b6c555ed2865250ad284b..fd6739d1e2350664cb55eb386b74a5999b4eac5b 100644 (file)
@@ -2154,10 +2154,16 @@ static void create_card_ports(struct userdata *u, pa_hashmap *ports) {
 }
 
 /* Run from main thread */
-static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid) {
+static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid, pa_hashmap *ports) {
+    pa_device_port *input_port, *output_port;
     pa_card_profile *p = NULL;
     enum profile *d;
 
+    pa_assert(u->input_port_name);
+    pa_assert(u->output_port_name);
+    pa_assert_se(input_port = pa_hashmap_get(ports, u->input_port_name));
+    pa_assert_se(output_port = pa_hashmap_get(ports, u->output_port_name));
+
     if (pa_streq(uuid, A2DP_SINK_UUID)) {
         p = pa_card_profile_new("a2dp", _("High Fidelity Playback (A2DP)"), sizeof(enum profile));
         p->priority = 10;
@@ -2165,6 +2171,7 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid
         p->n_sources = 0;
         p->max_sink_channels = 2;
         p->max_source_channels = 0;
+        pa_hashmap_put(output_port->profiles, p->name, p);
 
         d = PA_CARD_PROFILE_DATA(p);
         *d = PROFILE_A2DP;
@@ -2175,6 +2182,7 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid
         p->n_sources = 1;
         p->max_sink_channels = 0;
         p->max_source_channels = 2;
+        pa_hashmap_put(input_port->profiles, p->name, p);
 
         d = PA_CARD_PROFILE_DATA(p);
         *d = PROFILE_A2DP_SOURCE;
@@ -2185,6 +2193,8 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid
         p->n_sources = 1;
         p->max_sink_channels = 1;
         p->max_source_channels = 1;
+        pa_hashmap_put(input_port->profiles, p->name, p);
+        pa_hashmap_put(output_port->profiles, p->name, p);
 
         d = PA_CARD_PROFILE_DATA(p);
         *d = PROFILE_HSP;
@@ -2195,6 +2205,8 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid
         p->n_sources = 1;
         p->max_sink_channels = 1;
         p->max_source_channels = 1;
+        pa_hashmap_put(input_port->profiles, p->name, p);
+        pa_hashmap_put(output_port->profiles, p->name, p);
 
         d = PA_CARD_PROFILE_DATA(p);
         *d = PROFILE_HFGW;
@@ -2255,7 +2267,7 @@ static int add_card(struct userdata *u) {
     create_card_ports(u, data.ports);
 
     PA_LLIST_FOREACH(uuid, device->uuids) {
-        p = create_card_profile(u, uuid->uuid);
+        p = create_card_profile(u, uuid->uuid, data.ports);
 
         if (!p)
             continue;
@@ -2362,7 +2374,7 @@ static pa_hook_result_t uuid_added_cb(pa_bluetooth_discovery *y, const struct pa
     if (data->device != u->device)
         return PA_HOOK_OK;
 
-    p = create_card_profile(u, data->uuid);
+    p = create_card_profile(u, data->uuid, u->card->ports);
 
     if (!p)
         return PA_HOOK_OK;