mirror of
https://gitlab.freedesktop.org/pulseaudio/pulseaudio.git
synced 2025-11-04 13:29:59 -05:00
bluetooth: Report a2dp_source volume changes to the source device
Write the current volume to the `Volume` DBus property to keep the volume on the remote in sync. Without this the remote device shows the wrong volume, and any attempts to change it will cause an unexpected jump when the local volume has also been adjusted. Thanks to prior investments to improve volume synchronization, setting up callbacks and sending initial volume to the peer for HFP/HSP implementing this feature is as easy as unconditionally assigning a valid function to `set_source_volume`. `source_setup_volume_callback` is already responsible for attaching a `SOURCE_VOLUME_CHANGED` hook and sending initial (restored) volume to the peer (signifying support for Absolute Volume - if not derived from the presence of FEATURE_CATEGORY_2 on the profile yet). Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/239>
This commit is contained in:
parent
ac21b07ad6
commit
c6b771537e
2 changed files with 35 additions and 5 deletions
|
|
@ -905,6 +905,8 @@ static void source_setup_volume_callback(pa_source *s) {
|
|||
* If the peer is an AG however backend-native unconditionally provides this
|
||||
* function, PA in the role of HS/HF is responsible for signalling support
|
||||
* by emitting an initial volume command.
|
||||
* For A2DP bluez-util also unconditionally provides this function to keep
|
||||
* the peer informed about volume changes.
|
||||
*/
|
||||
if (!u->transport->set_source_volume)
|
||||
return;
|
||||
|
|
@ -921,6 +923,13 @@ static void source_setup_volume_callback(pa_source *s) {
|
|||
/* Send initial volume to peer, signalling support for volume control */
|
||||
u->transport->set_source_volume(u->transport, pa_cvolume_max(&s->real_volume));
|
||||
} else {
|
||||
/* It is yet unknown how (if at all) volume is synchronized for bidirectional
|
||||
* A2DP codecs. Disallow attaching callbacks (and using HFP n_volume_steps)
|
||||
* below to a pa_source if the peer is in A2DP_SINK role. This assert should
|
||||
* be replaced with the proper logic when bidirectional codecs are implemented.
|
||||
*/
|
||||
pa_assert(u->profile != PA_BLUETOOTH_PROFILE_A2DP_SINK);
|
||||
|
||||
if (s->set_volume == source_set_volume_cb)
|
||||
return;
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue