media-session: add bluez-autoswitch module

Add module that switches bluez device profile to HFP/HSP if an input
stream (non-monitor, autoconnect) appears, and the current default
output device is bluez one that does not have input route.

When all input streams are gone, switch all changed profiles back.

Pending restore state is saved to session manager state files, in order
to restore it if e.g. devices get disconnected.  This usually is not
currently necessary since the bluez5 plugin prefers to connect to A2DP
over HFP, but might matter in future with backchannel-enabled A2DP
codecs.
This commit is contained in:
Pauli Virtanen 2021-07-30 19:40:32 +03:00 committed by Wim Taymans
parent 127781cfc8
commit 76bae0cac4
6 changed files with 625 additions and 0 deletions

View file

@ -87,6 +87,12 @@ rules = [
# Profile connected first
# Available values: a2dp-sink (default), headset-head-unit
#device.profile = a2dp-sink
# A2DP <-> HFP profile auto-switching (when device is default output)
# Available values: false, role (default), true
# 'role' will switch the profile if the recording application
# specifies Communication (or "phone" in PA) as the stream role.
#bluez5.autoswitch-profile = role
}
}
}

View file

@ -86,6 +86,7 @@ session.modules = {
#alsa-seq # alsa seq midi support
#alsa-monitor # alsa udev detection
#bluez5 # bluetooth support
#bluez5-autoswitch # automatic bluetooth HSP/HFP profile switch
#restore-stream # restore stream settings
#logind # systemd-logind seat support
]
@ -106,6 +107,7 @@ session.modules = {
with-pulseaudio = [
with-audio
bluez5
bluez5-autoswitch
logind
restore-stream
streams-follow-default