bluetooth: Synchronize AVRCP Absolute Volume with A2DP sink
authorMarijn Suijten <marijns95@gmail.com>
Thu, 16 Jan 2020 01:49:01 +0000 (02:49 +0100)
committerPulseAudio Marge Bot <pulseaudio-maintainers@lists.freedesktop.org>
Mon, 17 May 2021 14:50:03 +0000 (14:50 +0000)
commitac21b07ad6ba2d0454ab54118359f9b5b1172db2
treeb4b89392c09d730ed04ae12f57247861e7aa666b
parent710a35cdc3581afc52ea167d42681bfecae5dd4f
bluetooth: Synchronize AVRCP Absolute Volume with A2DP sink

Like the previous commit this handles `Volume` property changes but
applies them to an A2DP sink instead of source stream.  As mentioned in
the AVRCP spec v1.6.2 ยง5.8 the rendering device (A2DP sink) is
responsible for performing volume attenuation meaning PulseAudio should
pass through audio as-is without performing any attenuation in SW.
Setting a valid pointer to `set_sink_volume` and returning `true` from
`should_attenuate_volume` attaches a hardware callback to `pa_sink` such
that no volume attenuation is performed anymore.

In addition to receiving volume change notifications it is also possible
to control remote volume by writing a new value to the DBus property.
This is especially useful when playing back to in-ear audio devices
which usually lack physical buttons to adjust the final volume on the
sink.

While software volume (used before this patch) is generally fine it is
annoying to crank it up all the way to 100% when a previous connection
to a different device left saved volume on the peer at a low volume.
Providing this bidirectional synchronization is most natural to users
who wish to use physical controls on their headphones, are used to this
from their smartphone, or aforementioned volume mismatches where both PA
as source and the peer as sink/rendering device are performing
attenutation.

Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/239>
src/modules/bluetooth/bluez5-util.c
src/modules/bluetooth/module-bluez5-device.c