Skip to content

Commit

Permalink
sfos: bluez5: Handle profile activation on off profile.
Browse files Browse the repository at this point in the history
HFP/HSP headsets may initiate transport when they are connected
but the transport is down. When this happens switch to the
profile associated with the headset.
  • Loading branch information
jusa committed Mar 22, 2019
1 parent a3c6eb1 commit 9b2dc55
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions src/modules/bluetooth/module-bluez5-device.c
Expand Up @@ -2313,6 +2313,19 @@ static pa_hook_result_t transport_state_changed_cb(pa_bluetooth_discovery *y, pa
if (t == u->transport && t->state <= PA_BLUETOOTH_TRANSPORT_STATE_DISCONNECTED)
pa_assert_se(pa_card_set_profile(u->card, pa_hashmap_get(u->card->profiles, "off"), false) >= 0);

if (!u->transport &&
u->profile == PA_BLUETOOTH_PROFILE_OFF &&
t->state == PA_BLUETOOTH_TRANSPORT_STATE_PLAYING) {

pa_log_debug("transport state changed without our initiate");
if (t->profile != PA_BLUETOOTH_PROFILE_A2DP_SINK &&
t->profile != PA_BLUETOOTH_PROFILE_A2DP_SOURCE) {

pa_log_debug("set card profile to %s", pa_bluetooth_profile_to_string(t->profile));
pa_card_set_profile(u->card, pa_hashmap_get(u->card->profiles, pa_bluetooth_profile_to_string(t->profile)), false);
}
}

if (t->device == u->device)
handle_transport_state_change(u, t);

Expand Down

0 comments on commit 9b2dc55

Please sign in to comment.