summaryrefslogtreecommitdiffstats
path: root/meta/recipes-multimedia/pulseaudio
diff options
context:
space:
mode:
authorJussi Kukkonen <jussi.kukkonen@intel.com>2015-11-24 15:44:46 +0200
committerRichard Purdie <richard.purdie@linuxfoundation.org>2015-12-01 21:32:10 +0000
commitd99958a9095f496a0ba7a1f1e5947b5dee1c0f9d (patch)
tree24b909c1f06511dbb3cf37f94cb357d6687367f6 /meta/recipes-multimedia/pulseaudio
parent2ba954fcb22b63b4881e1f8e38d15efdc38b4fd4 (diff)
downloadpoky-d99958a9095f496a0ba7a1f1e5947b5dee1c0f9d.tar.gz
pulseaudio: Fix HDMI profile selection
On systems with two cards, the correct output profile does not get selected automatically even in the simple case where there is one available profile. This scenario is typical at least with HDMI audio (which is on a separate card). Fixes [YOCTO #8448] (From OE-Core rev: 4bd76b8b292a81ce12d316557ffc9c6a79a7b5c1) Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com> Signed-off-by: Ross Burton <ross.burton@intel.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-multimedia/pulseaudio')
-rw-r--r--meta/recipes-multimedia/pulseaudio/pulseaudio/0001-card-add-pa_card_profile.ports.patch245
-rw-r--r--meta/recipes-multimedia/pulseaudio/pulseaudio/0002-alsa-bluetooth-fail-if-user-requested-profile-doesn-.patch60
-rw-r--r--meta/recipes-multimedia/pulseaudio/pulseaudio/0003-card-move-profile-selection-after-pa_card_new.patch363
-rw-r--r--meta/recipes-multimedia/pulseaudio/pulseaudio/0004-alsa-set-availability-for-some-unavailable-profiles.patch75
-rw-r--r--meta/recipes-multimedia/pulseaudio/pulseaudio_6.0.bb4
5 files changed, 747 insertions, 0 deletions
diff --git a/meta/recipes-multimedia/pulseaudio/pulseaudio/0001-card-add-pa_card_profile.ports.patch b/meta/recipes-multimedia/pulseaudio/pulseaudio/0001-card-add-pa_card_profile.ports.patch
new file mode 100644
index 0000000000..97b2e4064a
--- /dev/null
+++ b/meta/recipes-multimedia/pulseaudio/pulseaudio/0001-card-add-pa_card_profile.ports.patch
@@ -0,0 +1,245 @@
1From 6f814b40a01d03f93b36184c19339033949de472 Mon Sep 17 00:00:00 2001
2From: Tanu Kaskinen <tanuk@iki.fi>
3Date: Fri, 23 Oct 2015 12:23:13 +0300
4Subject: [PATCH 1/4] card: add pa_card_profile.ports
5
6Having ports accessible from pa_card_profile allows checking whether all ports
7of a profile are unavailable, and therefore helps with managing the profile
8availability (implemented in a later patch).
9
10http://bugzilla.yoctoproject.org/show_bug.cgi?id=8448
11
12Upstream-Status: Submitted [http://lists.freedesktop.org/archives/pulseaudio-discuss/2015-October/024614.html]
13Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
14---
15 src/modules/alsa/alsa-mixer.c | 4 +++-
16 src/modules/alsa/alsa-ucm.c | 1 +
17 src/modules/bluetooth/module-bluez4-device.c | 6 ++++++
18 src/modules/bluetooth/module-bluez5-device.c | 6 ++++++
19 src/pulsecore/card.c | 16 ++++++++++++++++
20 src/pulsecore/card.h | 18 ++++++++++++------
21 src/pulsecore/device-port.c | 7 ++++++-
22 7 files changed, 50 insertions(+), 8 deletions(-)
23
24diff --git a/src/modules/alsa/alsa-mixer.c b/src/modules/alsa/alsa-mixer.c
25index 47cbd14..c5b82b0 100644
26--- a/src/modules/alsa/alsa-mixer.c
27+++ b/src/modules/alsa/alsa-mixer.c
28@@ -4654,8 +4654,10 @@ static pa_device_port* device_port_alsa_init(pa_hashmap *ports, /* card ports */
29 path->port = p;
30 }
31
32- if (cp)
33+ if (cp) {
34 pa_hashmap_put(p->profiles, cp->name, cp);
35+ pa_card_profile_add_port(cp, p);
36+ }
37
38 if (extra) {
39 pa_hashmap_put(extra, p->name, p);
40diff --git a/src/modules/alsa/alsa-ucm.c b/src/modules/alsa/alsa-ucm.c
41index aa2d601..c8199d6 100644
42--- a/src/modules/alsa/alsa-ucm.c
43+++ b/src/modules/alsa/alsa-ucm.c
44@@ -761,6 +761,7 @@ static void ucm_add_port_combination(
45 if (cp) {
46 pa_log_debug("Adding profile %s to port %s.", cp->name, port->name);
47 pa_hashmap_put(port->profiles, cp->name, cp);
48+ pa_card_profile_add_port(cp, port);
49 }
50
51 if (hash) {
52diff --git a/src/modules/bluetooth/module-bluez4-device.c b/src/modules/bluetooth/module-bluez4-device.c
53index db69d34..b40c6a0 100644
54--- a/src/modules/bluetooth/module-bluez4-device.c
55+++ b/src/modules/bluetooth/module-bluez4-device.c
56@@ -2183,6 +2183,7 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid
57 p->max_sink_channels = 2;
58 p->max_source_channels = 0;
59 pa_hashmap_put(output_port->profiles, p->name, p);
60+ pa_card_profile_add_port(p, output_port);
61
62 d = PA_CARD_PROFILE_DATA(p);
63 *d = PA_BLUEZ4_PROFILE_A2DP;
64@@ -2194,6 +2195,7 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid
65 p->max_sink_channels = 0;
66 p->max_source_channels = 2;
67 pa_hashmap_put(input_port->profiles, p->name, p);
68+ pa_card_profile_add_port(p, input_port);
69
70 d = PA_CARD_PROFILE_DATA(p);
71 *d = PA_BLUEZ4_PROFILE_A2DP_SOURCE;
72@@ -2206,6 +2208,8 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid
73 p->max_source_channels = 1;
74 pa_hashmap_put(input_port->profiles, p->name, p);
75 pa_hashmap_put(output_port->profiles, p->name, p);
76+ pa_card_profile_add_port(p, input_port);
77+ pa_card_profile_add_port(p, output_port);
78
79 d = PA_CARD_PROFILE_DATA(p);
80 *d = PA_BLUEZ4_PROFILE_HSP;
81@@ -2218,6 +2222,8 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid
82 p->max_source_channels = 1;
83 pa_hashmap_put(input_port->profiles, p->name, p);
84 pa_hashmap_put(output_port->profiles, p->name, p);
85+ pa_card_profile_add_port(p, input_port);
86+ pa_card_profile_add_port(p, output_port);
87
88 d = PA_CARD_PROFILE_DATA(p);
89 *d = PA_BLUEZ4_PROFILE_HFGW;
90diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c
91index 7238e6f..3321785 100644
92--- a/src/modules/bluetooth/module-bluez5-device.c
93+++ b/src/modules/bluetooth/module-bluez5-device.c
94@@ -1790,6 +1790,7 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid
95 cp->max_sink_channels = 2;
96 cp->max_source_channels = 0;
97 pa_hashmap_put(output_port->profiles, cp->name, cp);
98+ pa_card_profile_add_port(cp, output_port);
99
100 p = PA_CARD_PROFILE_DATA(cp);
101 *p = PA_BLUETOOTH_PROFILE_A2DP_SINK;
102@@ -1801,6 +1802,7 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid
103 cp->max_sink_channels = 0;
104 cp->max_source_channels = 2;
105 pa_hashmap_put(input_port->profiles, cp->name, cp);
106+ pa_card_profile_add_port(cp, input_port);
107
108 p = PA_CARD_PROFILE_DATA(cp);
109 *p = PA_BLUETOOTH_PROFILE_A2DP_SOURCE;
110@@ -1813,6 +1815,8 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid
111 cp->max_source_channels = 1;
112 pa_hashmap_put(input_port->profiles, cp->name, cp);
113 pa_hashmap_put(output_port->profiles, cp->name, cp);
114+ pa_card_profile_add_port(cp, input_port);
115+ pa_card_profile_add_port(cp, output_port);
116
117 p = PA_CARD_PROFILE_DATA(cp);
118 *p = PA_BLUETOOTH_PROFILE_HEADSET_HEAD_UNIT;
119@@ -1825,6 +1829,8 @@ static pa_card_profile *create_card_profile(struct userdata *u, const char *uuid
120 cp->max_source_channels = 1;
121 pa_hashmap_put(input_port->profiles, cp->name, cp);
122 pa_hashmap_put(output_port->profiles, cp->name, cp);
123+ pa_card_profile_add_port(cp, input_port);
124+ pa_card_profile_add_port(cp, output_port);
125
126 p = PA_CARD_PROFILE_DATA(cp);
127 *p = PA_BLUETOOTH_PROFILE_HEADSET_AUDIO_GATEWAY;
128diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c
129index 6f9391e..cc4c784 100644
130--- a/src/pulsecore/card.c
131+++ b/src/pulsecore/card.c
132@@ -50,6 +50,7 @@ pa_card_profile *pa_card_profile_new(const char *name, const char *description,
133 c->n_sinks = c->n_sources = 0;
134 c->max_sink_channels = c->max_source_channels = 0;
135 c->available = PA_AVAILABLE_UNKNOWN;
136+ c->ports = pa_hashmap_new(pa_idxset_string_hash_func, pa_idxset_string_compare_func);
137
138 return c;
139 }
140@@ -57,11 +58,25 @@ pa_card_profile *pa_card_profile_new(const char *name, const char *description,
141 void pa_card_profile_free(pa_card_profile *c) {
142 pa_assert(c);
143
144+ if (c->ports) {
145+ pa_device_port *port;
146+ void *state;
147+ PA_HASHMAP_FOREACH(port, c->ports, state)
148+ pa_hashmap_remove (port->profiles, c->name);
149+ pa_hashmap_free(c->ports);
150+ }
151+
152 pa_xfree(c->name);
153 pa_xfree(c->description);
154 pa_xfree(c);
155 }
156
157+void pa_card_profile_add_port(pa_card_profile *profile, pa_device_port *port) {
158+ pa_assert(profile);
159+
160+ pa_hashmap_put(profile->ports, port->name, port);
161+}
162+
163 void pa_card_profile_set_available(pa_card_profile *c, pa_available_t available) {
164 pa_core *core;
165
166@@ -198,6 +213,7 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
167
168 c->userdata = NULL;
169 c->set_profile = NULL;
170+ c->active_profile = NULL;
171
172 pa_device_init_description(c->proplist, c);
173 pa_device_init_icon(c->proplist, true);
174diff --git a/src/pulsecore/card.h b/src/pulsecore/card.h
175index 3e2c004..1c33958 100644
176--- a/src/pulsecore/card.h
177+++ b/src/pulsecore/card.h
178@@ -22,19 +22,21 @@
179
180 typedef struct pa_card pa_card;
181
182-#include <pulse/proplist.h>
183-#include <pulsecore/core.h>
184-#include <pulsecore/module.h>
185-#include <pulsecore/idxset.h>
186-
187 /* This enum replaces pa_port_available_t (defined in pulse/def.h) for
188- * internal use, so make sure both enum types stay in sync. */
189+ * internal use, so make sure both enum types stay in sync. This is defined
190+ * before the #includes, because device-port.h depends on this enum. */
191 typedef enum pa_available {
192 PA_AVAILABLE_UNKNOWN = 0,
193 PA_AVAILABLE_NO = 1,
194 PA_AVAILABLE_YES = 2,
195 } pa_available_t;
196
197+#include <pulse/proplist.h>
198+#include <pulsecore/core.h>
199+#include <pulsecore/device-port.h>
200+#include <pulsecore/module.h>
201+#include <pulsecore/idxset.h>
202+
203 typedef struct pa_card_profile {
204 pa_card *card;
205 char *name;
206@@ -43,6 +45,8 @@ typedef struct pa_card_profile {
207 unsigned priority;
208 pa_available_t available; /* PA_AVAILABLE_UNKNOWN, PA_AVAILABLE_NO or PA_AVAILABLE_YES */
209
210+ pa_hashmap *ports; /* port name -> pa_device_port */
211+
212 /* We probably want to have different properties later on here */
213 unsigned n_sinks;
214 unsigned n_sources;
215@@ -100,6 +104,8 @@ typedef struct pa_card_new_data {
216 pa_card_profile *pa_card_profile_new(const char *name, const char *description, size_t extra);
217 void pa_card_profile_free(pa_card_profile *c);
218
219+void pa_card_profile_add_port(pa_card_profile *profile, pa_device_port *port);
220+
221 /* The profile's available status has changed */
222 void pa_card_profile_set_available(pa_card_profile *c, pa_available_t available);
223
224diff --git a/src/pulsecore/device-port.c b/src/pulsecore/device-port.c
225index cfe2a80..f16ecef 100644
226--- a/src/pulsecore/device-port.c
227+++ b/src/pulsecore/device-port.c
228@@ -95,8 +95,13 @@ static void device_port_free(pa_object *o) {
229 if (p->proplist)
230 pa_proplist_free(p->proplist);
231
232- if (p->profiles)
233+ if (p->profiles) {
234+ pa_card_profile *profile;
235+ void *state;
236+ PA_HASHMAP_FOREACH(profile, p->profiles, state)
237+ pa_hashmap_remove (profile->ports, p->name);
238 pa_hashmap_free(p->profiles);
239+ }
240
241 pa_xfree(p->name);
242 pa_xfree(p->description);
243--
2442.1.4
245
diff --git a/meta/recipes-multimedia/pulseaudio/pulseaudio/0002-alsa-bluetooth-fail-if-user-requested-profile-doesn-.patch b/meta/recipes-multimedia/pulseaudio/pulseaudio/0002-alsa-bluetooth-fail-if-user-requested-profile-doesn-.patch
new file mode 100644
index 0000000000..c3f217bc64
--- /dev/null
+++ b/meta/recipes-multimedia/pulseaudio/pulseaudio/0002-alsa-bluetooth-fail-if-user-requested-profile-doesn-.patch
@@ -0,0 +1,60 @@
1From 339eb179baa7810113f6456accc05b3a32c1cdba Mon Sep 17 00:00:00 2001
2From: Tanu Kaskinen <tanuk@iki.fi>
3Date: Fri, 23 Oct 2015 12:36:34 +0300
4Subject: [PATCH 2/4] alsa, bluetooth: fail if user-requested profile doesn't
5 exist
6
7If we can't fulfill the user request fully, I think we shouldn't
8fulfill it at all, to make it clear that the requested operation
9didn't succeed.
10
11http://bugzilla.yoctoproject.org/show_bug.cgi?id=8448
12
13Upstream-Status: Submitted [http://lists.freedesktop.org/archives/pulseaudio-discuss/2015-October/024614.html]
14Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
15---
16 src/modules/alsa/module-alsa-card.c | 10 ++++++++--
17 src/modules/bluetooth/module-bluez4-device.c | 6 ++++--
18 2 files changed, 12 insertions(+), 4 deletions(-)
19
20diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
21index a7fec04..32f517e 100644
22--- a/src/modules/alsa/module-alsa-card.c
23+++ b/src/modules/alsa/module-alsa-card.c
24@@ -754,8 +754,14 @@ int pa__init(pa_module *m) {
25 goto fail;
26 }
27
28- if ((profile = pa_modargs_get_value(u->modargs, "profile", NULL)))
29- pa_card_new_data_set_profile(&data, profile);
30+ if ((profile = pa_modargs_get_value(u->modargs, "profile", NULL))) {
31+ if (pa_hashmap_get(data.profiles, profile))
32+ pa_card_new_data_set_profile(&data, profile);
33+ else {
34+ pa_log("No such profile: %s", profile);
35+ goto fail;
36+ }
37+ }
38
39 u->card = pa_card_new(m->core, &data);
40 pa_card_new_data_done(&data);
41diff --git a/src/modules/bluetooth/module-bluez4-device.c b/src/modules/bluetooth/module-bluez4-device.c
42index b40c6a0..94e6988 100644
43--- a/src/modules/bluetooth/module-bluez4-device.c
44+++ b/src/modules/bluetooth/module-bluez4-device.c
45@@ -2310,8 +2310,10 @@ static int add_card(struct userdata *u) {
46 if ((default_profile = pa_modargs_get_value(u->modargs, "profile", NULL))) {
47 if (pa_hashmap_get(data.profiles, default_profile))
48 pa_card_new_data_set_profile(&data, default_profile);
49- else
50- pa_log_warn("Profile '%s' not valid or not supported by device.", default_profile);
51+ else {
52+ pa_log("Profile '%s' not valid or not supported by device.", default_profile);
53+ return -1;
54+ }
55 }
56
57 u->card = pa_card_new(u->core, &data);
58--
592.1.4
60
diff --git a/meta/recipes-multimedia/pulseaudio/pulseaudio/0003-card-move-profile-selection-after-pa_card_new.patch b/meta/recipes-multimedia/pulseaudio/pulseaudio/0003-card-move-profile-selection-after-pa_card_new.patch
new file mode 100644
index 0000000000..9585f3d529
--- /dev/null
+++ b/meta/recipes-multimedia/pulseaudio/pulseaudio/0003-card-move-profile-selection-after-pa_card_new.patch
@@ -0,0 +1,363 @@
1From cc41c8a3149ef04d4aa2db3d15032605a5504658 Mon Sep 17 00:00:00 2001
2From: Tanu Kaskinen <tanuk@iki.fi>
3Date: Fri, 23 Oct 2015 12:59:53 +0300
4Subject: [PATCH 3/4] card: move profile selection after pa_card_new()
5
6I want module-alsa-card to set the availability of unavailable
7profiles before the initial card profile gets selected, so that the
8selection logic can use correct availability information.
9module-alsa-card initializes the jack state after calling
10pa_card_new(), however, and the profile selection happens in
11pa_card_new(). This patch solves that by introducing pa_card_put() and
12moving the profile selection code there.
13
14An alternative solution would have been to move the jack
15initialization to happen before pa_card_new() and use pa_card_new_data
16instead of pa_card in the jack initialization code, but I disliked
17that idea (I want to get rid of the "new data" pattern eventually).
18
19The CARD_NEW hook is used when applying the initial profile policy, so
20that was moved to pa_card_put(). That required changing the hook data
21from pa_card_new_data to pa_card. module-card-restore now uses
22pa_card_set_profile() instead of pa_card_new_data_set_profile(). That
23required adding a state variable to pa_card, because
24pa_card_set_profile() needs to distinguish between setting the initial
25profile and setting the profile in other situations.
26
27The order in which the initial profile policy is applied is reversed
28in this patch. Previously the first one to set it won, now the last
29one to set it wins. I think this is better, because if you have N
30parties that want to set the profile, we avoid checking N times
31whether someone else has already set the profile.
32
33http://bugzilla.yoctoproject.org/show_bug.cgi?id=8448
34
35Upstream-Status: Submitted [http://lists.freedesktop.org/archives/pulseaudio-discuss/2015-October/024614.html]
36Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
37---
38 src/modules/alsa/module-alsa-card.c | 19 +++---
39 src/modules/bluetooth/module-bluez4-device.c | 18 +++---
40 src/modules/bluetooth/module-bluez5-device.c | 1 +
41 src/modules/macosx/module-coreaudio-device.c | 1 +
42 src/modules/module-card-restore.c | 24 ++++----
43 src/pulsecore/card.c | 86 +++++++++++++++-------------
44 src/pulsecore/card.h | 7 +++
45 7 files changed, 87 insertions(+), 69 deletions(-)
46
47diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
48index 32f517e..5b39654 100644
49--- a/src/modules/alsa/module-alsa-card.c
50+++ b/src/modules/alsa/module-alsa-card.c
51@@ -754,15 +754,6 @@ int pa__init(pa_module *m) {
52 goto fail;
53 }
54
55- if ((profile = pa_modargs_get_value(u->modargs, "profile", NULL))) {
56- if (pa_hashmap_get(data.profiles, profile))
57- pa_card_new_data_set_profile(&data, profile);
58- else {
59- pa_log("No such profile: %s", profile);
60- goto fail;
61- }
62- }
63-
64 u->card = pa_card_new(m->core, &data);
65 pa_card_new_data_done(&data);
66
67@@ -773,6 +764,16 @@ int pa__init(pa_module *m) {
68 u->card->set_profile = card_set_profile;
69
70 init_jacks(u);
71+ pa_card_put(u->card);
72+
73+ if ((profile = pa_modargs_get_value(u->modargs, "profile", NULL))) {
74+ u->card->active_profile = pa_hashmap_get(u->card->profiles, profile);
75+ if (!u->card->active_profile) {
76+ pa_log("No such profile: %s", profile);
77+ goto fail;
78+ }
79+ }
80+
81 init_profile(u);
82 init_eld_ctls(u);
83
84diff --git a/src/modules/bluetooth/module-bluez4-device.c b/src/modules/bluetooth/module-bluez4-device.c
85index 94e6988..5efc5dc 100644
86--- a/src/modules/bluetooth/module-bluez4-device.c
87+++ b/src/modules/bluetooth/module-bluez4-device.c
88@@ -2307,15 +2307,6 @@ static int add_card(struct userdata *u) {
89 *d = PA_BLUEZ4_PROFILE_OFF;
90 pa_hashmap_put(data.profiles, p->name, p);
91
92- if ((default_profile = pa_modargs_get_value(u->modargs, "profile", NULL))) {
93- if (pa_hashmap_get(data.profiles, default_profile))
94- pa_card_new_data_set_profile(&data, default_profile);
95- else {
96- pa_log("Profile '%s' not valid or not supported by device.", default_profile);
97- return -1;
98- }
99- }
100-
101 u->card = pa_card_new(u->core, &data);
102 pa_card_new_data_done(&data);
103
104@@ -2326,6 +2317,15 @@ static int add_card(struct userdata *u) {
105
106 u->card->userdata = u;
107 u->card->set_profile = card_set_profile;
108+ pa_card_put(u->card);
109+
110+ if ((default_profile = pa_modargs_get_value(u->modargs, "profile", NULL))) {
111+ u->card->active_profile = pa_hashmap_get(u->card->profiles, default_profile);
112+ if (!u->card->active_profile) {
113+ pa_log("Profile '%s' not valid or not supported by device.", default_profile);
114+ return -1;
115+ }
116+ }
117
118 d = PA_CARD_PROFILE_DATA(u->card->active_profile);
119
120diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c
121index 3321785..0081a21 100644
122--- a/src/modules/bluetooth/module-bluez5-device.c
123+++ b/src/modules/bluetooth/module-bluez5-device.c
124@@ -1959,6 +1959,7 @@ static int add_card(struct userdata *u) {
125
126 u->card->userdata = u;
127 u->card->set_profile = set_profile_cb;
128+ pa_card_put(u->card);
129
130 p = PA_CARD_PROFILE_DATA(u->card->active_profile);
131 u->profile = *p;
132diff --git a/src/modules/macosx/module-coreaudio-device.c b/src/modules/macosx/module-coreaudio-device.c
133index 4bbb5d5..41f151f 100644
134--- a/src/modules/macosx/module-coreaudio-device.c
135+++ b/src/modules/macosx/module-coreaudio-device.c
136@@ -764,6 +764,7 @@ int pa__init(pa_module *m) {
137 pa_card_new_data_done(&card_new_data);
138 u->card->userdata = u;
139 u->card->set_profile = card_set_profile;
140+ pa_card_put(u->card);
141
142 u->rtpoll = pa_rtpoll_new();
143 pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll);
144diff --git a/src/modules/module-card-restore.c b/src/modules/module-card-restore.c
145index baa2f4f..0501ac8 100644
146--- a/src/modules/module-card-restore.c
147+++ b/src/modules/module-card-restore.c
148@@ -485,34 +485,38 @@ static pa_hook_result_t port_offset_change_callback(pa_core *c, pa_device_port *
149 return PA_HOOK_OK;
150 }
151
152-static pa_hook_result_t card_new_hook_callback(pa_core *c, pa_card_new_data *new_data, struct userdata *u) {
153+static pa_hook_result_t card_new_hook_callback(pa_core *c, pa_card *card, struct userdata *u) {
154 struct entry *e;
155 void *state;
156 pa_device_port *p;
157 struct port_info *p_info;
158
159- pa_assert(new_data);
160+ pa_assert(c);
161+ pa_assert(card);
162+ pa_assert(u);
163
164- if (!(e = entry_read(u, new_data->name)))
165+ if (!(e = entry_read(u, card->name)))
166 return PA_HOOK_OK;
167
168 if (e->profile[0]) {
169- if (!new_data->active_profile) {
170- pa_card_new_data_set_profile(new_data, e->profile);
171- pa_log_info("Restored profile '%s' for card %s.", new_data->active_profile, new_data->name);
172- new_data->save_profile = true;
173+ pa_card_profile *profile;
174
175+ profile = pa_hashmap_get(card->profiles, e->profile);
176+ if (profile) {
177+ pa_card_set_profile(card, profile, true);
178+ pa_log_info("Restored profile '%s' for card %s.", card->active_profile->name, card->name);
179 } else
180- pa_log_debug("Not restoring profile for card %s, because already set.", new_data->name);
181+ pa_log_debug("Tried to restore profile %s for card %s, but the card doesn't have such profile.",
182+ e->profile, card->name);
183 }
184
185 /* Always restore the latency offsets because their
186 * initial value is always 0 */
187
188- pa_log_info("Restoring port latency offsets for card %s.", new_data->name);
189+ pa_log_info("Restoring port latency offsets for card %s.", card->name);
190
191 PA_HASHMAP_FOREACH(p_info, e->ports, state)
192- if ((p = pa_hashmap_get(new_data->ports, p_info->name)))
193+ if ((p = pa_hashmap_get(card->ports, p_info->name)))
194 p->latency_offset = p_info->offset;
195
196 entry_free(e);
197diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c
198index cc4c784..1b7f71b 100644
199--- a/src/pulsecore/card.c
200+++ b/src/pulsecore/card.c
201@@ -151,6 +151,7 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
202 pa_assert(!pa_hashmap_isempty(data->profiles));
203
204 c = pa_xnew(pa_card, 1);
205+ c->state = PA_CARD_STATE_INIT;
206
207 if (!(name = pa_namereg_register(core, data->name, PA_NAMEREG_CARD, c, data->namereg_fail))) {
208 pa_xfree(c);
209@@ -159,12 +160,6 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
210
211 pa_card_new_data_set_name(data, name);
212
213- if (pa_hook_fire(&core->hooks[PA_CORE_HOOK_CARD_NEW], data) < 0) {
214- pa_xfree(c);
215- pa_namereg_unregister(core, name);
216- return NULL;
217- }
218-
219 c->core = core;
220 c->name = pa_xstrdup(data->name);
221 c->proplist = pa_proplist_copy(data->proplist);
222@@ -187,30 +182,6 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
223 PA_HASHMAP_FOREACH(port, c->ports, state)
224 port->card = c;
225
226- c->active_profile = NULL;
227- c->save_profile = false;
228-
229- if (data->active_profile)
230- if ((c->active_profile = pa_hashmap_get(c->profiles, data->active_profile)))
231- c->save_profile = data->save_profile;
232-
233- if (!c->active_profile) {
234- PA_HASHMAP_FOREACH(profile, c->profiles, state) {
235- if (profile->available == PA_AVAILABLE_NO)
236- continue;
237-
238- if (!c->active_profile || profile->priority > c->active_profile->priority)
239- c->active_profile = profile;
240- }
241- /* If all profiles are not available, then we still need to pick one */
242- if (!c->active_profile) {
243- PA_HASHMAP_FOREACH(profile, c->profiles, state)
244- if (!c->active_profile || profile->priority > c->active_profile->priority)
245- c->active_profile = profile;
246- }
247- pa_assert(c->active_profile);
248- }
249-
250 c->userdata = NULL;
251 c->set_profile = NULL;
252 c->active_profile = NULL;
253@@ -219,13 +190,39 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
254 pa_device_init_icon(c->proplist, true);
255 pa_device_init_intended_roles(c->proplist);
256
257- pa_assert_se(pa_idxset_put(core->cards, c, &c->index) >= 0);
258+ return c;
259+}
260
261- pa_log_info("Created %u \"%s\"", c->index, c->name);
262- pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_NEW, c->index);
263+void pa_card_put(pa_card *card) {
264+ pa_card_profile *profile;
265+ void *state;
266
267- pa_hook_fire(&core->hooks[PA_CORE_HOOK_CARD_PUT], c);
268- return c;
269+ pa_assert(card);
270+
271+ PA_HASHMAP_FOREACH(profile, card->profiles, state) {
272+ if (profile->available == PA_AVAILABLE_NO)
273+ continue;
274+
275+ if (!card->active_profile || profile->priority > card->active_profile->priority)
276+ card->active_profile = profile;
277+ }
278+
279+ /* If all profiles are unavailable, then we still need to pick one */
280+ if (!card->active_profile) {
281+ PA_HASHMAP_FOREACH(profile, card->profiles, state)
282+ if (!card->active_profile || profile->priority > card->active_profile->priority)
283+ card->active_profile = profile;
284+ }
285+ pa_assert(card->active_profile);
286+
287+ pa_hook_fire(&card->core->hooks[PA_CORE_HOOK_CARD_NEW], card);
288+
289+ pa_assert_se(pa_idxset_put(card->core->cards, card, &card->index) >= 0);
290+ card->state = PA_CARD_STATE_LINKED;
291+
292+ pa_log_info("Created %u \"%s\"", card->index, card->name);
293+ pa_hook_fire(&card->core->hooks[PA_CORE_HOOK_CARD_PUT], card);
294+ pa_subscription_post(card->core, PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_NEW, card->index);
295 }
296
297 void pa_card_free(pa_card *c) {
298@@ -292,17 +289,24 @@ int pa_card_set_profile(pa_card *c, pa_card_profile *profile, bool save) {
299 return 0;
300 }
301
302- if ((r = c->set_profile(c, profile)) < 0)
303+ /* If we're setting the initial profile, we shouldn't call set_profile(),
304+ * because the implementations don't expect that (for historical reasons).
305+ * We should just set c->active_profile, and the implementations will
306+ * properly set up that profile after pa_card_put() has returned. It would
307+ * be probably good to change this so that also the initial profile can be
308+ * set up in set_profile(), but if set_profile() fails, that would need
309+ * some better handling than what we do here currently. */
310+ if (c->state != PA_CARD_STATE_INIT && (r = c->set_profile(c, profile)) < 0)
311 return r;
312
313- pa_subscription_post(c->core, PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_CHANGE, c->index);
314-
315- pa_log_info("Changed profile of card %u \"%s\" to %s", c->index, c->name, profile->name);
316-
317 c->active_profile = profile;
318 c->save_profile = save;
319
320- pa_hook_fire(&c->core->hooks[PA_CORE_HOOK_CARD_PROFILE_CHANGED], c);
321+ if (c->state != PA_CARD_STATE_INIT) {
322+ pa_log_info("Changed profile of card %u \"%s\" to %s", c->index, c->name, profile->name);
323+ pa_hook_fire(&c->core->hooks[PA_CORE_HOOK_CARD_PROFILE_CHANGED], c);
324+ pa_subscription_post(c->core, PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_CHANGE, c->index);
325+ }
326
327 return 0;
328 }
329diff --git a/src/pulsecore/card.h b/src/pulsecore/card.h
330index 1c33958..dbbc1c2 100644
331--- a/src/pulsecore/card.h
332+++ b/src/pulsecore/card.h
333@@ -37,6 +37,11 @@ typedef enum pa_available {
334 #include <pulsecore/module.h>
335 #include <pulsecore/idxset.h>
336
337+typedef enum pa_card_state {
338+ PA_CARD_STATE_INIT,
339+ PA_CARD_STATE_LINKED,
340+} pa_card_state_t;
341+
342 typedef struct pa_card_profile {
343 pa_card *card;
344 char *name;
345@@ -61,6 +66,7 @@ typedef struct pa_card_profile {
346
347 struct pa_card {
348 uint32_t index;
349+ pa_card_state_t state;
350 pa_core *core;
351
352 char *name;
353@@ -115,6 +121,7 @@ void pa_card_new_data_set_profile(pa_card_new_data *data, const char *profile);
354 void pa_card_new_data_done(pa_card_new_data *data);
355
356 pa_card *pa_card_new(pa_core *c, pa_card_new_data *data);
357+void pa_card_put(pa_card *c);
358 void pa_card_free(pa_card *c);
359
360 void pa_card_add_profile(pa_card *c, pa_card_profile *profile);
361--
3622.1.4
363
diff --git a/meta/recipes-multimedia/pulseaudio/pulseaudio/0004-alsa-set-availability-for-some-unavailable-profiles.patch b/meta/recipes-multimedia/pulseaudio/pulseaudio/0004-alsa-set-availability-for-some-unavailable-profiles.patch
new file mode 100644
index 0000000000..bb318aa06e
--- /dev/null
+++ b/meta/recipes-multimedia/pulseaudio/pulseaudio/0004-alsa-set-availability-for-some-unavailable-profiles.patch
@@ -0,0 +1,75 @@
1From 0136b73158f60d5dc630ae348b18df3b59a2a5c2 Mon Sep 17 00:00:00 2001
2From: Tanu Kaskinen <tanuk@iki.fi>
3Date: Fri, 23 Oct 2015 13:37:11 +0300
4Subject: [PATCH 4/4] alsa: set availability for (some) unavailable profiles
5
6The alsa card hasn't so far set any availability for profiles. That
7caused an issue with some HDMI hardware: the sound card has two HDMI
8outputs, but only the second of them is actually usable. The
9unavailable port is marked as unavailable and the available port is
10marked as available, but this information isn't propagated to the
11profile availability. Without profile availability information, the
12initial profile policy picks the unavailable one, since it has a
13higher priority value.
14
15This patch adds simple logic for marking some profiles unavailable:
16if the profile only contains unavailable ports, the profile is
17unavailable too. This can be improved in the future so that if a
18profile contains sinks or sources that only contain unavailable ports,
19the profile should be marked as unavailable. Implementing that
20requires adding more information about the sinks and sources to
21pa_card_profile, however.
22
23BugLink: https://bugzilla.yoctoproject.org/show_bug.cgi?id=8448
24
25Upstream-Status: Submitted [http://lists.freedesktop.org/archives/pulseaudio-discuss/2015-October/024614.html]
26Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
27---
28 src/modules/alsa/module-alsa-card.c | 24 ++++++++++++++++++++++++
29 1 file changed, 24 insertions(+)
30
31diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
32index 5b39654..73a846c 100644
33--- a/src/modules/alsa/module-alsa-card.c
34+++ b/src/modules/alsa/module-alsa-card.c
35@@ -366,6 +366,7 @@ static int report_jack_state(snd_mixer_elem_t *melem, unsigned int mask) {
36 void *state;
37 pa_alsa_jack *jack;
38 pa_device_port *port;
39+ pa_card_profile *profile;
40
41 pa_assert(u);
42
43@@ -396,6 +397,29 @@ static int report_jack_state(snd_mixer_elem_t *melem, unsigned int mask) {
44 }
45 report_port_state(port, u);
46 }
47+
48+ /* Update profile availabilities. The logic could be improved; for now we
49+ * only set obviously unavailable profiles (those that contain only
50+ * unavailable ports) to PA_AVAILABLE_NO and all others to
51+ * PA_AVAILABLE_UNKNOWN. */
52+ PA_HASHMAP_FOREACH(profile, u->card->profiles, state) {
53+ void *state2;
54+ pa_available_t available = PA_AVAILABLE_NO;
55+
56+ /* Don't touch the "off" profile. */
57+ if (pa_hashmap_size(profile->ports) == 0)
58+ continue;
59+
60+ PA_HASHMAP_FOREACH(port, profile->ports, state2) {
61+ if (port->available != PA_AVAILABLE_NO) {
62+ available = PA_AVAILABLE_UNKNOWN;
63+ break;
64+ }
65+ }
66+
67+ pa_card_profile_set_available(profile, available);
68+ }
69+
70 return 0;
71 }
72
73--
742.1.4
75
diff --git a/meta/recipes-multimedia/pulseaudio/pulseaudio_6.0.bb b/meta/recipes-multimedia/pulseaudio/pulseaudio_6.0.bb
index 31e9096389..ec629aa023 100644
--- a/meta/recipes-multimedia/pulseaudio/pulseaudio_6.0.bb
+++ b/meta/recipes-multimedia/pulseaudio/pulseaudio_6.0.bb
@@ -6,6 +6,10 @@ SRC_URI = "http://freedesktop.org/software/pulseaudio/releases/${BP}.tar.xz \
6 file://0001-conf-parser-add-support-for-.d-directories.patch \ 6 file://0001-conf-parser-add-support-for-.d-directories.patch \
7 file://fix-git-version-gen.patch \ 7 file://fix-git-version-gen.patch \
8 file://volatiles.04_pulse \ 8 file://volatiles.04_pulse \
9 file://0001-card-add-pa_card_profile.ports.patch \
10 file://0002-alsa-bluetooth-fail-if-user-requested-profile-doesn-.patch \
11 file://0003-card-move-profile-selection-after-pa_card_new.patch \
12 file://0004-alsa-set-availability-for-some-unavailable-profiles.patch \
9" 13"
10SRC_URI[md5sum] = "b691e83b7434c678dffacfa3a027750e" 14SRC_URI[md5sum] = "b691e83b7434c678dffacfa3a027750e"
11SRC_URI[sha256sum] = "b50640e0b80b1607600accfad2e45aabb79d379bf6354c9671efa2065477f6f6" 15SRC_URI[sha256sum] = "b50640e0b80b1607600accfad2e45aabb79d379bf6354c9671efa2065477f6f6"