From 0498e7a3d05c8ccd4f0389778e04f964f8a0b2f8 Mon Sep 17 00:00:00 2001 From: "Igor V. Kovalenko" Date: Mon, 6 Sep 2021 01:34:21 +0300 Subject: bluetooth: Do not use hardware volume control for A2DP backchannel Part-of: --- src/modules/bluetooth/module-bluez5-device.c | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c index 9c40a60ff..bac8ca4b2 100644 --- a/src/modules/bluetooth/module-bluez5-device.c +++ b/src/modules/bluetooth/module-bluez5-device.c @@ -964,6 +964,12 @@ static void source_setup_volume_callback(pa_source *s) { if (pa_bluetooth_profile_is_a2dp(u->profile) && !u->transport->device->avrcp_absolute_volume) return; + /* Do not use hardware volume controls for backchannel of A2DP sink */ + if (u->profile == PA_BLUETOOTH_PROFILE_A2DP_SINK) { + pa_assert_fp(u->transport->bt_codec && u->transport->bt_codec->support_backchannel); + return; + } + /* Remote volume control has to be supported for the callback to make sense, * otherwise this source should continue performing attenuation in software * without HW_VOLUME_CTL. @@ -1032,6 +1038,12 @@ static int add_source(struct userdata *u) { if (!u->transport_acquired) switch (u->profile) { + case PA_BLUETOOTH_PROFILE_A2DP_SINK: + if (u->bt_codec && u->bt_codec->support_backchannel) + data.suspend_cause = PA_SUSPEND_USER; + else + pa_assert_not_reached(); + break; case PA_BLUETOOTH_PROFILE_A2DP_SOURCE: case PA_BLUETOOTH_PROFILE_HFP_AG: case PA_BLUETOOTH_PROFILE_HSP_AG: @@ -1046,7 +1058,6 @@ static int add_source(struct userdata *u) { else pa_assert_not_reached(); break; - case PA_BLUETOOTH_PROFILE_A2DP_SINK: case PA_BLUETOOTH_PROFILE_OFF: pa_assert_not_reached(); break; @@ -1201,6 +1212,12 @@ static void sink_setup_volume_callback(pa_sink *s) { if (pa_bluetooth_profile_is_a2dp(u->profile) && !u->transport->device->avrcp_absolute_volume) return; + /* Do not use hardware volume controls for backchannel of A2DP source */ + if (u->profile == PA_BLUETOOTH_PROFILE_A2DP_SOURCE) { + pa_assert_fp(u->transport->bt_codec && u->transport->bt_codec->support_backchannel); + return; + } + /* Remote volume control has to be supported for the callback to make sense, * otherwise this sink should continue performing attenuation in software * without HW_VOLUME_CTL. -- cgit v1.2.1