If enabled, this setting will use the same volume levels as the previous
profile. This is useful on some bluetooth devices if the bluetooth profile
audioswitch is enabled.
This patch improves the BT profile autoswitch logic so that it is simpler and
more robust. Instead of just relying on capture clients that are linked to (or
unlinked from) the BT loopback source node to evaluate whether we have to switch
to a headset profile or not, we now also evaluate the autoswitch every time the
BT loopback source node state changes. This avoids problems with some capture
clients that pause the input stream without closing them.
Apart from this, the patch also fixes some issues with saved profiles if the
user manually switched to a headset profile when no capture streams are present.
The autoswitch logic should restore back the non-headset profile (A2DP) every
time a capture client is disconnected or the BT loopback source node stops
running.
Finally, the 'bluetooth.autoswitch-to-headset-profile' setting will now register
or remove the necessary hooks depending on whether the setting is enabled or
disabled, improving WirePlumber performance if autoswitching is disabled.
This script mutes available output ALSA routes if an audio node that was
previously running was removed. This is useful for cases where users might
unplug their headset accidentaly, causing undesired loud audio to play on the
Speakers.
Two new settings are added to chose whether the user wants to do this for
ALSA devices, Bluetooth devices or both. The settings are set to false by
default.
Finally, a notification is also sent to notify the user that the devices were
muted.
A "Voice Call" profile is supposed to be active during a call, even if
there is a higher priority device profile. Add a hook to select the
Voice Call profile when a call is active, and select a profile when
transitioning in and out of an active call.
When applying new routes, we always want the save property to be false because
it is done by WirePlumber (not the user). WirePlumber applies routes when
restoring them from the state file, or when finding the best routes after the
profile has changed. In both cases, it does not make sense to set save=true.
If the user changed the volume on a ACP 'Headphones' route to a value different
than 100%, and then unplugs the jack headset, the ACP 'Headphones' route becomes
unavailable with volume set to 100% and the save flag not cleared.
Since the save flag is not cleared when the ACP 'Headphones' route becomes
unavailable, WirePlumber will save it with 100% volume, overriding the previous
volume value set by the user. This is not ideal because the volume will be
restored to 100% by WirePlumber when plugging back the headset.
This change fixes this by never saving routes that are not available.
The Route params changed event can be emitted before the EnumRoute params with
some devices, causing wrong evaluation of the routes because their cached info
is not updated. This change always enumerates the EnumRoute params before
evaluating them to make sure the cache info is always valid.
Fixes: #762
This patch adds a 500ms timeout callback to switch to HSP/HFP when a stream
starts capturing BT audio. This avoids quickly switching from A2DP to HSP/HFP
back and forth if an application just wants to probe the BT source for a short
period of time.
See #634
Handle only devices associated with Bluetooth loopback nodes.
Make sure the node.link-group iteration cannot get stuck if there is a
loop in the link graph.
This patch removes the manually created object managers in the BT profile
autoswitch logic, and instead uses the object managers from the event source,
simplifying the logic a bit.
This should never happen, but there are odd cases with broken
configuration where such a device may appear and the least we can do
is not crash, at least not when the device.name is only used for
debug messages. In state-profile and other places where the name
really matters, we actually have checks in place.
Fixes: #674
We always have to destroy the restore timeout source when we want to switch to
HSP/HFP profile, even if the device is already set to HSP/HFP or has already an
input route. Apart from this, we also want to make sure there is no pending
timeout source when we are creating a new one. This should avoid an infinite
loop about switching BT profiles when capture nodes are created and destroyed
quickly.
If a source filter is used, the BT profile autoswitch does not work because
WirePlumber thinks there is always a client capturing audio from it. This patch
fixes the issue by recursively walking through the source filters that are
linked to the BT loopback source until a stream is found. If a stream is found
at the end of the chain, then it switches to HSP/HFP profile, if the stream is
not found, the profile stays to A2DP.
event:set_data() coerces Lua tables to properties, so that keys and
values become strings. Take into account that profile.index is a string
due to this.
Fixes WP setting the profile, even though it is already the active one.
Autoswitch should make sure the saved headset profile always has an
input route. Check this on loading/saving it, otherwise reselect it.
Headset mode profile without mic used to make some sense when it wasn't
using the loopback node (ie. easy way to disable it), but now with the
loopback node this doesn't make sense any more and it's confusing if it
occurs, so we shouldn't allow it.
Like WirePlumber 0.4.17, we need to mark the current routes as 'active' if they
were previously not active as soon as we detect it. This avoids a possible
infinite loop that restores the routes and saves them constantly, which happens
when the device's Route param has changed more than once before the event
'select-routes' is triggered.
Cache the rules in a global variable in each script, as JSON,
and use JsonUtils directly to evaluate them. This will allow us to
close the WpConf in the future after loading the scripts.
Also change the order of the return values of the match_rules_apply_properties
function to be able to easily ignore the number of changed values,
which is useless in most cases.
This patch improves the bluetooth profile autoswitch so that it works with any
application that wants to capture from a bluetooth device. To do so, a loopback
source filter is created per connected bluetooth device. If an application wants
to capture audio from such loopback source filter, the profile in the associated
bluetooth device is changed to HSP/HFP. If there isn't any application connected
to the loopback source filter, the profile switches back to A2DP.
When a manual change is applied, the store-or-restore-routes is the only
hook that gets executed for this event. In order to be able to test if a
route was changed, we need to reset all of them to 'active = false',
record the previous value of 'active' and test their difference.
Testing only the 'active' variable (and discarding 'prev_active') sounds
tempting here, but if a route is changed back and forth (from A to B
and back to A), there is nothing to reset the 'active' variable of A
when it gets deactivated and it will appear as previously active on
the second switch.
Related to: #551
* rename settings to make more sense
* split out monitor settings into a separate category
* add setting for restoring the default nodes in the node category
Do not continue iteration over all other profiles when
we found the profile set in the 'device.profile' property.
In other case we would overwrite this profile when
we find a best_profile.
This patch updates the deprecated policy-bluetooth.lua script so that it works
with the current version. The script has been moved into the device sub-folder,
and renamed to autoswitch-blueooth-profile.lua. The settings-manager is also
used for the configuration, and the actual configuration has been moved from
linkind.conf to bluetooth.conf.