bluetooth: Request headset audio during profile switch

When a headset is having a profile switch, we can either leave the
SCO state unmodified (as it was before this patch) or we can
alternatively request it (as older versions of PA).

This patch tries to avoid a potential regression in case a module
such as module-suspend-on-idle is not present, due to the provided
resume-on-running policy. Without this patch, and without such a policy,
the sink and sources would stay suspended until the user manually
performed another profile switch (i.e. hsp->off->hsp).

There are several other solutions currently being discussed as a longer
term solution, some of which require extendind the core. This patch is
therefore proposed as a short-term workaround to avoid the regression.
This commit is contained in:
Mikel Astiz 2012-12-03 11:03:59 +01:00 committed by Tanu Kaskinen
parent 01435e6134
commit bbb47c67bb

View file

@ -1743,7 +1743,7 @@ static int add_sink(struct userdata *u) {
switch (u->profile) { switch (u->profile) {
case PROFILE_A2DP: case PROFILE_A2DP:
case PROFILE_HSP: case PROFILE_HSP:
data.suspend_cause = PA_SUSPEND_IDLE; pa_assert_not_reached(); /* Profile switch should have failed */
break; break;
case PROFILE_HFGW: case PROFILE_HFGW:
data.suspend_cause = PA_SUSPEND_USER; data.suspend_cause = PA_SUSPEND_USER;
@ -1818,7 +1818,7 @@ static int add_source(struct userdata *u) {
if (!bt_transport_is_acquired(u)) if (!bt_transport_is_acquired(u))
switch (u->profile) { switch (u->profile) {
case PROFILE_HSP: case PROFILE_HSP:
data.suspend_cause = PA_SUSPEND_IDLE; pa_assert_not_reached(); /* Profile switch should have failed */
break; break;
case PROFILE_A2DP_SOURCE: case PROFILE_A2DP_SOURCE:
case PROFILE_HFGW: case PROFILE_HFGW:
@ -2011,7 +2011,10 @@ static int setup_transport(struct userdata *u) {
u->transport_removed_slot = pa_hook_connect(&t->hooks[PA_BLUETOOTH_TRANSPORT_HOOK_REMOVED], PA_HOOK_NORMAL, u->transport_removed_slot = pa_hook_connect(&t->hooks[PA_BLUETOOTH_TRANSPORT_HOOK_REMOVED], PA_HOOK_NORMAL,
(pa_hook_cb_t) transport_removed_cb, u); (pa_hook_cb_t) transport_removed_cb, u);
bt_transport_acquire(u, FALSE); if (u->profile == PROFILE_A2DP_SOURCE || u->profile == PROFILE_HFGW)
bt_transport_acquire(u, FALSE); /* In case of error, the sink/sources will be created suspended */
else if (bt_transport_acquire(u, TRUE) < 0)
return -1; /* We need to fail here until the interactions with module-suspend-on-idle and alike get improved */
bt_transport_config(u); bt_transport_config(u);