summaryrefslogtreecommitdiffstats
path: root/meta/recipes-multimedia/pulseaudio/pulseaudio/0003-card-move-profile-selection-after-pa_card_new.patch
diff options
context:
space:
mode:
Diffstat (limited to 'meta/recipes-multimedia/pulseaudio/pulseaudio/0003-card-move-profile-selection-after-pa_card_new.patch')
-rw-r--r--meta/recipes-multimedia/pulseaudio/pulseaudio/0003-card-move-profile-selection-after-pa_card_new.patch131
1 files changed, 67 insertions, 64 deletions
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
index 9585f3d529..0e7780154d 100644
--- 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
@@ -1,4 +1,4 @@
1From cc41c8a3149ef04d4aa2db3d15032605a5504658 Mon Sep 17 00:00:00 2001 1From 13e85dd1763e99d21a60323671b9a5df08bdae75 Mon Sep 17 00:00:00 2001
2From: Tanu Kaskinen <tanuk@iki.fi> 2From: Tanu Kaskinen <tanuk@iki.fi>
3Date: Fri, 23 Oct 2015 12:59:53 +0300 3Date: Fri, 23 Oct 2015 12:59:53 +0300
4Subject: [PATCH 3/4] card: move profile selection after pa_card_new() 4Subject: [PATCH 3/4] card: move profile selection after pa_card_new()
@@ -32,23 +32,30 @@ whether someone else has already set the profile.
32 32
33http://bugzilla.yoctoproject.org/show_bug.cgi?id=8448 33http://bugzilla.yoctoproject.org/show_bug.cgi?id=8448
34 34
35Upstream-Status: Submitted [http://lists.freedesktop.org/archives/pulseaudio-discuss/2015-October/024614.html]
36Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com> 35Signed-off-by: Jussi Kukkonen <jussi.kukkonen@intel.com>
36
37Rebased on 8.0.
38
39Upstream-Status: Denied [The patch set needs some work to be accepted.
40The review thread:
41http://thread.gmane.org/gmane.comp.audio.pulseaudio.general/24301]
42
43Signed-off-by: Tanu Kaskinen <tanuk@iki.fi>
37--- 44---
38 src/modules/alsa/module-alsa-card.c | 19 +++--- 45 src/modules/alsa/module-alsa-card.c | 19 +++----
39 src/modules/bluetooth/module-bluez4-device.c | 18 +++--- 46 src/modules/bluetooth/module-bluez4-device.c | 18 +++----
40 src/modules/bluetooth/module-bluez5-device.c | 1 + 47 src/modules/bluetooth/module-bluez5-device.c | 1 +
41 src/modules/macosx/module-coreaudio-device.c | 1 + 48 src/modules/macosx/module-coreaudio-device.c | 1 +
42 src/modules/module-card-restore.c | 24 ++++---- 49 src/modules/module-card-restore.c | 24 +++++----
43 src/pulsecore/card.c | 86 +++++++++++++++------------- 50 src/pulsecore/card.c | 81 +++++++++++++++-------------
44 src/pulsecore/card.h | 7 +++ 51 src/pulsecore/card.h | 7 +++
45 7 files changed, 87 insertions(+), 69 deletions(-) 52 7 files changed, 86 insertions(+), 65 deletions(-)
46 53
47diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c 54diff --git a/src/modules/alsa/module-alsa-card.c b/src/modules/alsa/module-alsa-card.c
48index 32f517e..5b39654 100644 55index 9e8cde2..fe240f0 100644
49--- a/src/modules/alsa/module-alsa-card.c 56--- a/src/modules/alsa/module-alsa-card.c
50+++ b/src/modules/alsa/module-alsa-card.c 57+++ b/src/modules/alsa/module-alsa-card.c
51@@ -754,15 +754,6 @@ int pa__init(pa_module *m) { 58@@ -770,15 +770,6 @@ int pa__init(pa_module *m) {
52 goto fail; 59 goto fail;
53 } 60 }
54 61
@@ -64,7 +71,7 @@ index 32f517e..5b39654 100644
64 u->card = pa_card_new(m->core, &data); 71 u->card = pa_card_new(m->core, &data);
65 pa_card_new_data_done(&data); 72 pa_card_new_data_done(&data);
66 73
67@@ -773,6 +764,16 @@ int pa__init(pa_module *m) { 74@@ -789,6 +780,16 @@ int pa__init(pa_module *m) {
68 u->card->set_profile = card_set_profile; 75 u->card->set_profile = card_set_profile;
69 76
70 init_jacks(u); 77 init_jacks(u);
@@ -82,10 +89,10 @@ index 32f517e..5b39654 100644
82 init_eld_ctls(u); 89 init_eld_ctls(u);
83 90
84diff --git a/src/modules/bluetooth/module-bluez4-device.c b/src/modules/bluetooth/module-bluez4-device.c 91diff --git a/src/modules/bluetooth/module-bluez4-device.c b/src/modules/bluetooth/module-bluez4-device.c
85index 94e6988..5efc5dc 100644 92index dd18217..5d0d3db 100644
86--- a/src/modules/bluetooth/module-bluez4-device.c 93--- a/src/modules/bluetooth/module-bluez4-device.c
87+++ b/src/modules/bluetooth/module-bluez4-device.c 94+++ b/src/modules/bluetooth/module-bluez4-device.c
88@@ -2307,15 +2307,6 @@ static int add_card(struct userdata *u) { 95@@ -2304,15 +2304,6 @@ static int add_card(struct userdata *u) {
89 *d = PA_BLUEZ4_PROFILE_OFF; 96 *d = PA_BLUEZ4_PROFILE_OFF;
90 pa_hashmap_put(data.profiles, p->name, p); 97 pa_hashmap_put(data.profiles, p->name, p);
91 98
@@ -101,7 +108,7 @@ index 94e6988..5efc5dc 100644
101 u->card = pa_card_new(u->core, &data); 108 u->card = pa_card_new(u->core, &data);
102 pa_card_new_data_done(&data); 109 pa_card_new_data_done(&data);
103 110
104@@ -2326,6 +2317,15 @@ static int add_card(struct userdata *u) { 111@@ -2323,6 +2314,15 @@ static int add_card(struct userdata *u) {
105 112
106 u->card->userdata = u; 113 u->card->userdata = u;
107 u->card->set_profile = card_set_profile; 114 u->card->set_profile = card_set_profile;
@@ -118,7 +125,7 @@ index 94e6988..5efc5dc 100644
118 d = PA_CARD_PROFILE_DATA(u->card->active_profile); 125 d = PA_CARD_PROFILE_DATA(u->card->active_profile);
119 126
120diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c 127diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c
121index 3321785..0081a21 100644 128index b015c67..7b90a31 100644
122--- a/src/modules/bluetooth/module-bluez5-device.c 129--- a/src/modules/bluetooth/module-bluez5-device.c
123+++ b/src/modules/bluetooth/module-bluez5-device.c 130+++ b/src/modules/bluetooth/module-bluez5-device.c
124@@ -1959,6 +1959,7 @@ static int add_card(struct userdata *u) { 131@@ -1959,6 +1959,7 @@ static int add_card(struct userdata *u) {
@@ -130,10 +137,10 @@ index 3321785..0081a21 100644
130 p = PA_CARD_PROFILE_DATA(u->card->active_profile); 137 p = PA_CARD_PROFILE_DATA(u->card->active_profile);
131 u->profile = *p; 138 u->profile = *p;
132diff --git a/src/modules/macosx/module-coreaudio-device.c b/src/modules/macosx/module-coreaudio-device.c 139diff --git a/src/modules/macosx/module-coreaudio-device.c b/src/modules/macosx/module-coreaudio-device.c
133index 4bbb5d5..41f151f 100644 140index 0c92d42..7190ee9 100644
134--- a/src/modules/macosx/module-coreaudio-device.c 141--- a/src/modules/macosx/module-coreaudio-device.c
135+++ b/src/modules/macosx/module-coreaudio-device.c 142+++ b/src/modules/macosx/module-coreaudio-device.c
136@@ -764,6 +764,7 @@ int pa__init(pa_module *m) { 143@@ -807,6 +807,7 @@ int pa__init(pa_module *m) {
137 pa_card_new_data_done(&card_new_data); 144 pa_card_new_data_done(&card_new_data);
138 u->card->userdata = u; 145 u->card->userdata = u;
139 u->card->set_profile = card_set_profile; 146 u->card->set_profile = card_set_profile;
@@ -142,10 +149,10 @@ index 4bbb5d5..41f151f 100644
142 u->rtpoll = pa_rtpoll_new(); 149 u->rtpoll = pa_rtpoll_new();
143 pa_thread_mq_init(&u->thread_mq, m->core->mainloop, u->rtpoll); 150 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 151diff --git a/src/modules/module-card-restore.c b/src/modules/module-card-restore.c
145index baa2f4f..0501ac8 100644 152index f906843..dce6674 100644
146--- a/src/modules/module-card-restore.c 153--- a/src/modules/module-card-restore.c
147+++ b/src/modules/module-card-restore.c 154+++ 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 * 155@@ -515,34 +515,38 @@ static pa_hook_result_t port_offset_change_callback(pa_core *c, pa_device_port *
149 return PA_HOOK_OK; 156 return PA_HOOK_OK;
150 } 157 }
151 158
@@ -189,24 +196,24 @@ index baa2f4f..0501ac8 100644
189+ pa_log_info("Restoring port latency offsets for card %s.", card->name); 196+ pa_log_info("Restoring port latency offsets for card %s.", card->name);
190 197
191 PA_HASHMAP_FOREACH(p_info, e->ports, state) 198 PA_HASHMAP_FOREACH(p_info, e->ports, state)
192- if ((p = pa_hashmap_get(new_data->ports, p_info->name))) 199- if ((p = pa_hashmap_get(new_data->ports, p_info->name))) {
193+ if ((p = pa_hashmap_get(card->ports, p_info->name))) 200+ if ((p = pa_hashmap_get(card->ports, p_info->name))) {
194 p->latency_offset = p_info->offset; 201 p->latency_offset = p_info->offset;
195 202 if (!p->preferred_profile && p_info->profile)
196 entry_free(e); 203 pa_device_port_set_preferred_profile(p, p_info->profile);
197diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c 204diff --git a/src/pulsecore/card.c b/src/pulsecore/card.c
198index cc4c784..1b7f71b 100644 205index f92ac87..1a6e705 100644
199--- a/src/pulsecore/card.c 206--- a/src/pulsecore/card.c
200+++ b/src/pulsecore/card.c 207+++ b/src/pulsecore/card.c
201@@ -151,6 +151,7 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) { 208@@ -148,6 +148,7 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
202 pa_assert(!pa_hashmap_isempty(data->profiles)); 209 pa_assert(!pa_hashmap_isempty(data->profiles));
203 210
204 c = pa_xnew(pa_card, 1); 211 c = pa_xnew0(pa_card, 1);
205+ c->state = PA_CARD_STATE_INIT; 212+ c->state = PA_CARD_STATE_INIT;
206 213
207 if (!(name = pa_namereg_register(core, data->name, PA_NAMEREG_CARD, c, data->namereg_fail))) { 214 if (!(name = pa_namereg_register(core, data->name, PA_NAMEREG_CARD, c, data->namereg_fail))) {
208 pa_xfree(c); 215 pa_xfree(c);
209@@ -159,12 +160,6 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) { 216@@ -156,12 +157,6 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
210 217
211 pa_card_new_data_set_name(data, name); 218 pa_card_new_data_set_name(data, name);
212 219
@@ -219,22 +226,24 @@ index cc4c784..1b7f71b 100644
219 c->core = core; 226 c->core = core;
220 c->name = pa_xstrdup(data->name); 227 c->name = pa_xstrdup(data->name);
221 c->proplist = pa_proplist_copy(data->proplist); 228 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) { 229@@ -184,38 +179,43 @@ pa_card *pa_card_new(pa_core *core, pa_card_new_data *data) {
223 PA_HASHMAP_FOREACH(port, c->ports, state) 230 PA_HASHMAP_FOREACH(port, c->ports, state)
224 port->card = c; 231 port->card = c;
225 232
226- c->active_profile = NULL;
227- c->save_profile = false;
228-
229- if (data->active_profile) 233- if (data->active_profile)
230- if ((c->active_profile = pa_hashmap_get(c->profiles, data->active_profile))) 234- if ((c->active_profile = pa_hashmap_get(c->profiles, data->active_profile)))
231- c->save_profile = data->save_profile; 235- c->save_profile = data->save_profile;
232- 236+ pa_device_init_description(c->proplist, c);
237+ pa_device_init_icon(c->proplist, true);
238+ pa_device_init_intended_roles(c->proplist);
239
233- if (!c->active_profile) { 240- if (!c->active_profile) {
234- PA_HASHMAP_FOREACH(profile, c->profiles, state) { 241- PA_HASHMAP_FOREACH(profile, c->profiles, state) {
235- if (profile->available == PA_AVAILABLE_NO) 242- if (profile->available == PA_AVAILABLE_NO)
236- continue; 243- continue;
237- 244+ return c;
245+}
246
238- if (!c->active_profile || profile->priority > c->active_profile->priority) 247- if (!c->active_profile || profile->priority > c->active_profile->priority)
239- c->active_profile = profile; 248- c->active_profile = profile;
240- } 249- }
@@ -245,27 +254,10 @@ index cc4c784..1b7f71b 100644
245- c->active_profile = profile; 254- c->active_profile = profile;
246- } 255- }
247- pa_assert(c->active_profile); 256- 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) { 257+void pa_card_put(pa_card *card) {
264+ pa_card_profile *profile; 258+ pa_card_profile *profile;
265+ void *state; 259+ void *state;
266 260+
267- pa_hook_fire(&core->hooks[PA_CORE_HOOK_CARD_PUT], c);
268- return c;
269+ pa_assert(card); 261+ pa_assert(card);
270+ 262+
271+ PA_HASHMAP_FOREACH(profile, card->profiles, state) { 263+ PA_HASHMAP_FOREACH(profile, card->profiles, state) {
@@ -274,8 +266,11 @@ index cc4c784..1b7f71b 100644
274+ 266+
275+ if (!card->active_profile || profile->priority > card->active_profile->priority) 267+ if (!card->active_profile || profile->priority > card->active_profile->priority)
276+ card->active_profile = profile; 268+ card->active_profile = profile;
277+ } 269 }
278+ 270
271- pa_device_init_description(c->proplist, c);
272- pa_device_init_icon(c->proplist, true);
273- pa_device_init_intended_roles(c->proplist);
279+ /* If all profiles are unavailable, then we still need to pick one */ 274+ /* If all profiles are unavailable, then we still need to pick one */
280+ if (!card->active_profile) { 275+ if (!card->active_profile) {
281+ PA_HASHMAP_FOREACH(profile, card->profiles, state) 276+ PA_HASHMAP_FOREACH(profile, card->profiles, state)
@@ -283,19 +278,24 @@ index cc4c784..1b7f71b 100644
283+ card->active_profile = profile; 278+ card->active_profile = profile;
284+ } 279+ }
285+ pa_assert(card->active_profile); 280+ pa_assert(card->active_profile);
286+ 281
282- pa_assert_se(pa_idxset_put(core->cards, c, &c->index) >= 0);
287+ pa_hook_fire(&card->core->hooks[PA_CORE_HOOK_CARD_NEW], card); 283+ pa_hook_fire(&card->core->hooks[PA_CORE_HOOK_CARD_NEW], card);
288+ 284
285- pa_log_info("Created %u \"%s\"", c->index, c->name);
286- pa_subscription_post(core, PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_NEW, c->index);
289+ pa_assert_se(pa_idxset_put(card->core->cards, card, &card->index) >= 0); 287+ pa_assert_se(pa_idxset_put(card->core->cards, card, &card->index) >= 0);
290+ card->state = PA_CARD_STATE_LINKED; 288+ card->state = PA_CARD_STATE_LINKED;
291+ 289
290- pa_hook_fire(&core->hooks[PA_CORE_HOOK_CARD_PUT], c);
291- return c;
292+ pa_log_info("Created %u \"%s\"", card->index, card->name); 292+ pa_log_info("Created %u \"%s\"", card->index, card->name);
293+ pa_hook_fire(&card->core->hooks[PA_CORE_HOOK_CARD_PUT], card); 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); 294+ pa_subscription_post(card->core, PA_SUBSCRIPTION_EVENT_CARD|PA_SUBSCRIPTION_EVENT_NEW, card->index);
295 } 295 }
296 296
297 void pa_card_free(pa_card *c) { 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) { 298@@ -306,20 +306,27 @@ int pa_card_set_profile(pa_card *c, pa_card_profile *profile, bool save) {
299 return 0; 299 return 0;
300 } 300 }
301 301
@@ -317,6 +317,9 @@ index cc4c784..1b7f71b 100644
317 c->active_profile = profile; 317 c->active_profile = profile;
318 c->save_profile = save; 318 c->save_profile = save;
319 319
320 if (save)
321 update_port_preferred_profile(c);
322
320- pa_hook_fire(&c->core->hooks[PA_CORE_HOOK_CARD_PROFILE_CHANGED], c); 323- pa_hook_fire(&c->core->hooks[PA_CORE_HOOK_CARD_PROFILE_CHANGED], c);
321+ if (c->state != PA_CARD_STATE_INIT) { 324+ 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); 325+ pa_log_info("Changed profile of card %u \"%s\" to %s", c->index, c->name, profile->name);
@@ -327,22 +330,22 @@ index cc4c784..1b7f71b 100644
327 return 0; 330 return 0;
328 } 331 }
329diff --git a/src/pulsecore/card.h b/src/pulsecore/card.h 332diff --git a/src/pulsecore/card.h b/src/pulsecore/card.h
330index 1c33958..dbbc1c2 100644 333index fff9057..a944301 100644
331--- a/src/pulsecore/card.h 334--- a/src/pulsecore/card.h
332+++ b/src/pulsecore/card.h 335+++ b/src/pulsecore/card.h
333@@ -37,6 +37,11 @@ typedef enum pa_available { 336@@ -34,6 +34,11 @@ typedef enum pa_available {
334 #include <pulsecore/module.h> 337 PA_AVAILABLE_YES = 2,
335 #include <pulsecore/idxset.h> 338 } pa_available_t;
336 339
337+typedef enum pa_card_state { 340+typedef enum pa_card_state {
338+ PA_CARD_STATE_INIT, 341+ PA_CARD_STATE_INIT,
339+ PA_CARD_STATE_LINKED, 342+ PA_CARD_STATE_LINKED,
340+} pa_card_state_t; 343+} pa_card_state_t;
341+ 344+
342 typedef struct pa_card_profile { 345 struct pa_card_profile {
343 pa_card *card; 346 pa_card *card;
344 char *name; 347 char *name;
345@@ -61,6 +66,7 @@ typedef struct pa_card_profile { 348@@ -66,6 +71,7 @@ struct pa_card_profile {
346 349
347 struct pa_card { 350 struct pa_card {
348 uint32_t index; 351 uint32_t index;
@@ -350,7 +353,7 @@ index 1c33958..dbbc1c2 100644
350 pa_core *core; 353 pa_core *core;
351 354
352 char *name; 355 char *name;
353@@ -115,6 +121,7 @@ void pa_card_new_data_set_profile(pa_card_new_data *data, const char *profile); 356@@ -120,6 +126,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); 357 void pa_card_new_data_done(pa_card_new_data *data);
355 358
356 pa_card *pa_card_new(pa_core *c, pa_card_new_data *data); 359 pa_card *pa_card_new(pa_core *c, pa_card_new_data *data);
@@ -359,5 +362,5 @@ index 1c33958..dbbc1c2 100644
359 362
360 void pa_card_add_profile(pa_card *c, pa_card_profile *profile); 363 void pa_card_add_profile(pa_card *c, pa_card_profile *profile);
361-- 364--
3622.1.4 3652.7.0
363 366