Split rescan-on-linkable triggering into a separate script file
(linking/rescan-on-linkable.lua) that can be disabled via
wireplumber.profiles by setting hooks.linking.rescan-on-linkable =
disabled.
Since 'autoswitch-*' events have lower priority than 'select-*' events,
this guarantees that the autoswitch hooks will always run after the
'device/apply-profile' hook, avoiding possible race conditions.
We cannot only rely on the input routes to check whether a profile is a headset
profile or not because some BT devices can have A2DP source nodes, causing the
autoswitch logic to not work properly.
This patch fixes the problem by also checking if the profile name matches the
'headset-head-unit*' or 'bap-duplex' patterns. If the profile name does not
match those patterns, the profile is not considered headset profile.
See #926
Setting api.bluez5.internal=true changes media.class to
Audio/(Stream|Sink)/Internal which makes HFP HF output get wrong media
class.
Don't set this for headset-audio-gateway. Fixes HFP HF stream media
class.
This allows us to have per-device configuration for device volumes, via
a `device.routes.default-volume` property. This allows a non-global
override for situations where we want to expose a different out-of-box
volume (say for an internal speaker where we know a better comfortable
default setting, or HDMI where we might want to avoid attenuation by
default).
At the moment the libcamera monitor and "Device" objects are loaded in the
wireplumber process, but the "Node" objects are loaded in the pipewire daemon.
Due to that, both processes have their own separate `libcamera::CameraManager`
objects. These operate independently.
As a consequence of the above, there is an inherent race condition: when a
new camera appears and the wireplumber process detects it and instructs the
pipewire process to create a "Node" for it, at that point, the camera might
not exist in the `CameraManager` of the "pipewire" process.
This can happen during the initial enumeration as well as hotplug. So load
the nodes locally in the wireplumber process so that all libcamera objects
use the same `CameraManager`, thus eliminating the race condition.
This is required in order to allow plugins to use GL as mincore
is used in Mesas `_eglPointerIsDereferenceable()`.
One example for a client wanting to do so is the in-development
libcamera GPUISP, see https://patchwork.libcamera.org/cover/24183/
(cherry picked from commit pipewire@4796b3fb9524c20ac0f5006143b6a13ee50c01ec)
See pipewire/pipewire!2530
Allows installation of systemd services without libsystemd installed.
Useful for Alpine Linux where systemd services are allowed to be subpackaged
(e.g. for postmarketOS) but hasn't systemd in it's repos.
It has no change in existing behavior, but installs services if the unit
directories are explicitly set.
This simplifies a lot the logic as we don't need to destroy and re-create the
internal BT nodes right away if the loopback nodes were create after them.
We also now listen for changes in the BT profile autoswitch setting. If the
setting is disabled, the source loopback is destroyed. If it is enabled, the
source loopack is created. This makes the setting to take effect immediately,
without needing to disconnect and re-connect the BT device for the setting to
take effect.
As properties are no longer Lua tables, we'll need to make a table copy
for the Json constructor.
Fixes assigning Json.Array to a non-table, and ending up with
"audio.position":"0x7b771267d690" instead of ["FL","FR"] in json output,
which caused BAP device set node to always have mono channels.
Use prefix matching instead of exact matching for media.class when
validating nodes in the set-default command. This allows virtual
nodes (e.g. Audio/Source/Virtual) to be set as default devices,
while still excluding internal nodes.
Fixes#896
Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
Audio/Sink nodes should only be used as default audio source node type if the
user has explicitly selected it. If the user has not explicitly selected it,
we should always ignore it and instead select the highest priority Audio/Source
node.
Fixes#886
Take the loopback nodes into account also in device Routes.
Some Pulseaudio applications (eg GNOME) determine what to do based on
device ports, so make sure they are consistent with what nodes will be
emitted.
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.
If the BT profile autoswitch setting is enabled, we also want to create a sink
loopback for SCO-A2DP sink nodes. Since BT nodes are removed and created again
when the profile changes, this avoids confusing some apps making them think
that the BT profile has not changed at all, because the loopback nodes are
always present, even when switching profiles.
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.
Add immediate linking for common cases to reduce latency when new
audio/video streams are added. The full rescan mechanism is preserved
and still triggers for all session-item-added events via the
rescan-trigger hook.
UCM alsa nodes don't seem to have the 'alsa.*' properties from the device
included, which make it harder to match those nodes with alsa rules. This
patch adds all the 'alsa.*' properties in the UCM node to solve this.
There are streams that should go to a speaker rather than a headphone
or earpiece by default. Examples are alarms and emergency alerts on
phones. Allow to set a preference via
`policy.role-based.preferred-target` which then looks up the target
via `node.name` and `node.nick`.
Signed-off-by: Guido Günther <agx@sigxcpu.org>
`rescan-for-linking` is the lowest priority linking event but the
`rescan-for-media-role-volume` event is lower overall priority.
Signed-off-by: Guido Günther <agx@sigxcpu.org>
When using role based priorities a volume slider presented to the
user should adjust the volume of the currently playing role.
E.g. when a phone has an incoming call and is ringing the default volume
slider should adjust the ringing volume and once the call has been
picked up it should adjust the call volume and once the call ended it
should adjust the media volume again.
It's currently hard for e.g. desktop shells to find out what a suitable
sink for volume control is so add a script to find a suitable target for
volume control (based on media role priority) by storing it's name in
the metadata.
Signed-off-by: Guido Günther <agx@sigxcpu.org>
This allows us to set up the device to use HDMI ELD information for
channels. Not yet documented while we experiment with different ways to
make this work.
Up until now, all the 'node.features.audio.*' settings did not have any effect
if changed at runtime. This patch fixes this by reconfiguring the audio adapters
every time those settings have changed.
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.