diff options
author | Marijn Suijten <marijns95@gmail.com> | 2021-04-22 21:59:37 +0200 |
---|---|---|
committer | PulseAudio Marge Bot <pulseaudio-maintainers@lists.freedesktop.org> | 2021-05-17 14:50:03 +0000 |
commit | d9db47bdb5074316d195357cff4eca98e208a405 (patch) | |
tree | b2b85d5f0fee2da05ea48ae4bdd5c8407e7e0fc6 /src/modules/bluetooth/module-bluez5-device.c | |
parent | 25426bc029892997a1cd36fe4782d1399643567b (diff) | |
download | pulseaudio-d9db47bdb5074316d195357cff4eca98e208a405.tar.gz |
bluetooth: Add avrcp_absolute_volume module flag for disablement
Not all peers might work fine with Absolute Volume, provide the user
with an option to disable it without impairing other AVRCP-related
commands like media status and playback controls.
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/239>
Diffstat (limited to 'src/modules/bluetooth/module-bluez5-device.c')
-rw-r--r-- | src/modules/bluetooth/module-bluez5-device.c | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/src/modules/bluetooth/module-bluez5-device.c b/src/modules/bluetooth/module-bluez5-device.c index 5dfe57652..993fac302 100644 --- a/src/modules/bluetooth/module-bluez5-device.c +++ b/src/modules/bluetooth/module-bluez5-device.c @@ -60,6 +60,7 @@ PA_MODULE_USAGE( "path=<device object path>" "autodetect_mtu=<boolean>" "output_rate_refresh_interval_ms=<interval between attempts to improve output rate in milliseconds>" + "avrcp_absolute_volume=<synchronize volume with peer, true by default>" ); #define FIXED_LATENCY_PLAYBACK_A2DP (25 * PA_USEC_PER_MSEC) @@ -71,6 +72,7 @@ static const char* const valid_modargs[] = { "path", "autodetect_mtu", "output_rate_refresh_interval_ms", + "avrcp_absolute_volume", NULL }; @@ -899,6 +901,9 @@ static void source_setup_volume_callback(pa_source *s) { pa_assert(u->source == s); pa_assert(u->transport); + if (pa_bluetooth_profile_is_a2dp(u->profile) && !u->transport->device->avrcp_absolute_volume) + 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. @@ -1124,6 +1129,9 @@ static void sink_setup_volume_callback(pa_sink *s) { pa_assert(u->sink == s); pa_assert(u->transport); + if (pa_bluetooth_profile_is_a2dp(u->profile) && !u->transport->device->avrcp_absolute_volume) + 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. @@ -2404,7 +2412,7 @@ static char *list_codecs(struct userdata *u) { pa_json_encoder_begin_element_array(encoder); - if (u->profile == PA_BLUETOOTH_PROFILE_A2DP_SINK || u->profile == PA_BLUETOOTH_PROFILE_A2DP_SOURCE) { + if (pa_bluetooth_profile_is_a2dp(u->profile)) { is_a2dp_sink = u->profile == PA_BLUETOOTH_PROFILE_A2DP_SINK; a2dp_endpoints = is_a2dp_sink ? u->device->a2dp_sink_endpoints : u->device->a2dp_source_endpoints; @@ -2620,7 +2628,7 @@ int pa__init(pa_module* m) { struct userdata *u; const char *path; pa_modargs *ma; - bool autodetect_mtu; + bool autodetect_mtu, avrcp_absolute_volume; char *message_handler_path; uint32_t output_rate_refresh_interval_ms; @@ -2669,6 +2677,14 @@ int pa__init(pa_module* m) { u->device->output_rate_refresh_interval_ms = output_rate_refresh_interval_ms; + avrcp_absolute_volume = true; + if (pa_modargs_get_value_boolean(ma, "avrcp_absolute_volume", &avrcp_absolute_volume) < 0) { + pa_log("Invalid boolean value for avrcp_absolute_volume parameter"); + goto fail_free_modargs; + } + + u->device->avrcp_absolute_volume = avrcp_absolute_volume; + pa_modargs_free(ma); u->device_connection_changed_slot = |