Skip to content

Commit

Permalink
sfos: bluez5: Don't create sinks or sources with droid backend.
Browse files Browse the repository at this point in the history
When running in droid setup we don't create sinks or sources,
as the reading and writing to headset is done through
droid.sink and droid.source with sco ports enabled.

Signed-off-by: Juho Hämäläinen <juho.hamalainen@jolla.com>
  • Loading branch information
jusa committed Feb 24, 2021
1 parent 049a6a4 commit e53e784
Showing 1 changed file with 27 additions and 1 deletion.
28 changes: 27 additions & 1 deletion src/modules/bluetooth/module-bluez5-device.c
Expand Up @@ -1325,6 +1325,16 @@ static int init_profile(struct userdata *u) {

pa_assert(u->transport);

/* droid headset profiles don't have sink or source,
* as the reading and writing to headset is done through
* droid.sink and droid.source with sco ports enabled.
* this module is used only for setting up the transport.
*/
if (u->profile != PA_BLUETOOTH_PROFILE_A2DP_SINK &&
u->profile != PA_BLUETOOTH_PROFILE_A2DP_SOURCE &&
pa_bluetooth_droid_backend(u->discovery))
return r;

if (get_profile_direction (u->profile) & PA_DIRECTION_OUTPUT)
if (add_sink(u) < 0)
r = -1;
Expand Down Expand Up @@ -2065,7 +2075,17 @@ static int add_card(struct userdata *u) {

u->card->userdata = u;
u->card->set_profile = set_profile_cb;
pa_card_choose_initial_profile(u->card);
/* SFOS specific change:
* Instead of calling now
* pa_card_choose_initial_profile(u->card);
* we just set active profile to Off.
* When policy framework sees this new card
* it will then choose proper profile based
* on current system state.
*/
u->card->active_profile = cp; /* off */
u->card->save_profile = false;
pa_hook_fire(&u->card->core->hooks[PA_CORE_HOOK_CARD_CHOOSE_INITIAL_PROFILE], u->card);
pa_card_put(u->card);

p = PA_CARD_PROFILE_DATA(u->card->active_profile);
Expand Down Expand Up @@ -2191,6 +2211,9 @@ static pa_hook_result_t transport_speaker_gain_changed_cb(pa_bluetooth_discovery
if (t != u->transport)
return PA_HOOK_OK;

if (pa_bluetooth_droid_backend(y))
return PA_HOOK_OK;

gain = t->speaker_gain;
volume = (pa_volume_t) (gain * PA_VOLUME_NORM / HSP_MAX_GAIN);

Expand Down Expand Up @@ -2218,6 +2241,9 @@ static pa_hook_result_t transport_microphone_gain_changed_cb(pa_bluetooth_discov
if (t != u->transport)
return PA_HOOK_OK;

if (pa_bluetooth_droid_backend(y))
return PA_HOOK_OK;

gain = t->microphone_gain;
volume = (pa_volume_t) (gain * PA_VOLUME_NORM / HSP_MAX_GAIN);

Expand Down

0 comments on commit e53e784

Please sign in to comment.