Commit graph

1005 commits

Author SHA1 Message Date
Pauli Virtanen
bc713acafd m-mpris: add MPRIS plugin
Add a plugin module that can list active MPRIS media players, and send
Pause commands to them.
2025-07-23 10:19:44 +03:00
George Kiagiadakis
faf042a82b wpctl: set-profile: set the "save" flag on the selected profile
Fixes: #808
2025-07-01 13:37:02 +03:00
George Kiagiadakis
e9928b4beb default-nodes/README: update documentation regarding the select-default-node event 2025-07-01 13:20:22 +03:00
George Kiagiadakis
754c805061 default-nodes/find-best: skip the hook if a very high priority node is selected
Just to optimize a bit more for performance
2025-07-01 13:13:21 +03:00
George Kiagiadakis
f1c96843ee default-nodes/rescan: remove unused table and access node.properties only once 2025-07-01 12:52:36 +03:00
Julian Bouzas
a433a49e28 default-nodes: Use session and route priorities when finding the default node
Some PCM devices can expose multiple nodes with same session priorities but
different route priorities. This improves the default nodes logic to also check
the route priorities when the session priorities are the same.
2025-07-01 12:52:36 +03:00
Julian Bouzas
84e2fcc050 monitor/alsa: Increase priority for USB devices
We always want the plugged USB ALSA device to have higher priority than the
internal ALSA device.
2025-06-26 14:05:38 -04:00
Richard Acayan
73f52cfb94 monitors/alsa: manage node when bound
If the managed node needs to emit events before it is bound, Wireplumber
treats it as destroyed and ignores the events. Add the node as pending
before it is bound so the node can run set_param on events that happen
before it gets bound.

Signed-off-by: Richard Acayan <mailingradian@gmail.com>
2025-06-23 08:02:46 +03:00
Tiago de Paula
ee42211bc6
fix: nil value in haveAvailableRoutes
Cause from partially renamed variables in af3c520d.

Closes #797
2025-05-21 01:00:59 -03:00
Julian Bouzas
0251d644a8 default-nodes/rescan: Check available routes using linking-utils
The linking-utils module already implements a way to check for available routes,
this patch uses it in default-nodes/rescan.lua to remove redundant code.
2025-05-18 14:11:53 +02:00
George Kiagiadakis
b8506d0d56 linking-utils: fix missing 'end' 2025-05-18 14:11:53 +02:00
George Kiagiadakis
af3c520d3e linking-utils: improve haveAvailableRoutes
Based on nodeHasAvailableRoutes() from default-nodes/rescan.lua
2025-05-18 13:56:14 +02:00
Pauli Virtanen
2d48caa74b monitors/alsa: fix nil table indexing
It's possible that managed_node.properties["node.name"] == nil if the
node is gone.

The removeDevice call above has already cleared the node names, so no
need to do it again.
2025-04-11 13:07:43 +00:00
George Kiagiadakis
9f440d0b50 monitors/libcamera: fix deduplicating devices with the same name 2025-04-11 15:53:44 +03:00
Lukas Riezler
e51e1b6080 v4l2/monitor: scripts: fix for deduplicate devices with the same name 2025-04-08 10:06:45 +02:00
Robert Mader
0d356f90ed monitor-utils: Support devices without any device ids
Such as libcameras virtual devices.
2025-04-07 17:04:22 +00:00
Andrew Sayers
1eed9669f1
Avoid spurious warnings when dbus.service stops
wireplumber.service generates the following when dbus.service
stops before it (e.g. when the user logs out):

    m-dbus-connection: <WpDBusConnection:0x556b3c561680> DBus connection closed: Underlying GIOStream returned 0 bytes on an async read
    m-dbus-connection: <WpDBusConnection:0x556b3c561680> Trying to reconnect after core sync

Stop the service before dbus.service exits, to avoid these messages.
2025-04-03 15:38:08 +01:00
Julian Bouzas
0b716118c7 scripts: Add audio-group-utils.lua to group audio streams
This allows grouping audio streams that have a pw-audio-namespace ancestor
process name. The grouping is done by creating a loopback filter for each group
or namespace. Those loopback filters are then linked in between the actual
stream and device nodes. A '--target-object' flag is also supported in the
ancestor process name to define a target for the loopback stream node.
2025-03-05 16:28:34 +02:00
Pauli Virtanen
78f1e34029 autoswitch-bluetooth-profile: use s-device log topic 2025-03-02 15:09:53 +02:00
Andrew Sayers
eec702e4a1
Use wp_info() on normal termination
The service is normally stopped by SIGTERM.  Using wp_info() here
means users will be more likely to notice abnormal exits.
2025-02-21 13:03:11 +00:00
Andrew Sayers
d91c366c2f
Change the new "skipping device" warning to debug
The other "skipping device" (a few lines later) uses log:debug,
so it makes sense for these to be the same.
2025-02-21 13:03:03 +00:00
Barnabás Pőcze
5846d12ea1 wpctl: fix types in variadic arguments
`wp_object_manager_add_interest()` passes the format string
and the arguments after that to `g_variant_new()`, which
requires a 32-bit integer for "u". Passing a 64-bit integer
will cause problems on certain ABIs.

Furthermore, remove the metadata related interest declaration
from `set_default_prepare()` since the "set-default" command
does not access metadata directly, it uses the "default-nodes-api"
plugin.

Fixes: 7784cfad92 ("wpctl: support @DEFAULT_{AUDIO,VIDEO}_{SINK,SOURCE}@ as ID ")
Fixes #773
2025-02-19 18:49:07 +01:00
Barnabás Pőcze
f3bc7168ed wpctl: fix default device name leak
The `get-default-configured-node-name` handler returns a copy
of the name of the node, hence it must be freed.
2025-02-19 18:35:42 +01:00
George Kiagiadakis
b031d3fcd1 scripts: populate session.services via a script
See pipewire!1409 / wireplumber!441
2025-02-07 11:05:44 +00:00
George Kiagiadakis
b8f0cf3644 monitors/bluez: make the source loopback node appear as non-virtual
Fixes: #729
2025-02-07 12:54:43 +02:00
luzpaz
cb770c1d7e docs: fix various codebase typos Found via codespell -q 3 -S "*.po,./po/*,NEWS.rst" -L bootup,gir,inout 2025-01-28 15:45:54 +01:00
Pauli Virtanen
899943bfcf monitors: disable stream-restore for device loopback nodes
stream-restore should not be touching node properties of the Bluetooth
mic / device set / offload / ALSA UCM split loopback nodes. Those are
controlled by Route settings on the device.

Set device.routes and state.restore-props=false as appropriate to avoid
that.
2025-01-26 21:33:22 +02:00
Pauli Virtanen
4d02d0275f monitors/alsa: provide splitting of UCM SplitPCM nodes
Instruct ACP to provide information about UCM SplitPCM channel
splitting instead of doing it with alsa-lib plugins.

Use the provided information to load loopbacks that create virtual sinks
that do the channel remapping from UCM.
2024-12-23 11:42:23 +02:00
Pauli Virtanen
027aba7f3b monitors/bluez: rename api.bluez5.id -> spa.object.id
Use same name as in alsa monitor.
2024-12-19 18:45:16 +02:00
Pauli Virtanen
ada687a4cc monitors/alsa: decouple name deduplication from node objects
Node name deduplication relying on presence of node objects creates race
conditions, as the name cannot be marked unused if the node object was
not created or was destroyed.

Use separate (device_id, node_id) -> name table to track name ownership
separately from the existence of node objects.

Also clear up the reserved names when device is destroyed, by the
monitor or device reservation.  In these cases "object-removed" for
nodes is not called, so this fixes names leaking when e.g. pw-reserve is
used.
2024-12-19 18:41:01 +02:00
Pauli Virtanen
65989e7e38 monitors: use WpSpaDevice:set_managed_pending()
In cases where a Node is created asynchronously and associated with the
Device later, set the id pending so that we don't miss ObjectConfig
events.

The "set Route again" workaround is also not needed, moreover it was not
reliable before either since the Device might issue ObjectConfig only
for changed properties.
2024-12-15 20:51:55 +02:00
Pauli Virtanen
4c1a6f5840 monitors/bluez: recreate SCO source when loopback is emitted
If loopback is emitted after the SCO node, e.g. when A2DP profile
connects late, recreate the SCO node.

This ensures the underlying SCO node is hidden when the loopback is
present.
2024-12-09 20:28:53 +02:00
George Kiagiadakis
4c07fd1da1 device: find-preferred-profile: define device_name variable
Fixes: #751
2024-12-02 12:18:42 +02:00
George Kiagiadakis
e76ebde6d8 conf.d.examples: improve alsa.conf
Completely remove references to auto-profile/auto-port.
It's better if users are not tempted to enable them.
2024-11-28 16:04:55 +02:00
George Kiagiadakis
f79d4b1b3b monitors: alsa: disable api.acp.auto-profile by default
This seems to be an omission from when we transferred the default device
properties from the config file on to the Lua script. Both auto-profile
and auto-port are meant to be disabled, so that we can apply our own
management logic.

Fixes: #734
2024-11-28 16:02:57 +02:00
George Kiagiadakis
77d2dcd97f autoswitch-bluetooth-profile.lua: drop local function declarations
There is no point in local functions in the global script scope.
We use a sandbox anyway to isolate from other scripts.
2024-11-28 11:55:38 +02:00
Pauli Virtanen
1ddb473deb monitors/alsa: handle node activation failure
When node activation fails, it won't be created and its object-removed
signal can be called with some properties missing.  This breaks node
name deduplication, causing error

wplua: [string "alsa.lua"]:182: attempt to concatenate a nil value (local 'node_name')

It occurs e.g. when switching ALSA device profile, while some
application has opened the device with ALSA and is keeping it busy.

Fix by handling the activation failure, and tolerating missing property
in object-removed.
2024-11-23 17:11:37 +02:00
Julian Bouzas
76985fff5b autoswitch-bluetooth-profile: Switch to HSP/HFP on timeout
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
2024-10-10 15:54:59 +00:00
Robert Mader
b2d2f656fd monitor-utils: Check all libcamera v4l2 devices
The actual deduplication only checked the first device. Extend it to the
full list, as intended.

Fixes: 848b6326 (monitor-utils: Rework camera deduplication code)
2024-10-03 10:46:49 +02:00
Robert Mader
848b6326a9 monitor-utils: Rework camera deduplication code
The previous code made some invalid assumptions and was rather
complicated. Rework and simplify it.

The approach work as follows:
1. Once a new device gets registered, store its data in a list of pending
   devices.
2. Start a timer. On timeout, we check all pending devices and depulicate
   according to our heuristic. The timer gets reset whenever a device is
   added in order to avoid race conditions.
3. On timeout, add the pending devices to categories. For now: UVC cameras
   from the V4L2 plugin, libcamera cameras and other cameras from the V4L2
   plugin.
4. Then process the different categories in order of preference and store
   their V4L2 device IDs in a list for each plugin.
5. Before creating a camera, check that the V4L2 device(s) it uses are not
   yet used by a already existing camera from the other plugin.

While on it, drop support for Pipewire versions that don't report V4L2
device IDs at all.

Closes https://gitlab.freedesktop.org/pipewire/wireplumber/-/issues/689
Closes https://gitlab.freedesktop.org/pipewire/wireplumber/-/issues/708
2024-09-30 01:06:40 +02:00
Pauli Virtanen
b68a6794cd autoswitch-bluetooth-profile: switch only Bluetooth devices
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.
2024-09-10 07:51:03 +00:00
George Kiagiadakis
40e5dbff3d systemd: load the system instance with the 'main-systemwide' profile by default
This can still be overriden in the configuration file, if needed.

See #608
2024-09-03 11:40:05 +03:00
George Kiagiadakis
43ea3db02c wireplumber.conf: add systemwide, embedded and split-instance profiles
Revamp the profiles section, making use of the inherits feature
and add commonly used profiles for systemwide & embedded use cases,
as well as profiles for a split-instance configuration where the
policy hooks run in a separate instance from the alsa, bluetooth
and camera monitors (which run in 3 separate instances respectively)

Also add an example on how to configure the loaded profile using
a config file instead of the CLI switch.

Fixes: #608
2024-09-03 11:39:10 +03:00
George Kiagiadakis
fae966558c wireplumber.conf: add before/after dependencies where needed
All hooks except the monitor ones should be loaded before the
standard-event-source and all the monitors should be loaded after.
2024-09-02 15:45:29 +03:00
George Kiagiadakis
32be79ee56 wireplumber.conf: improve the v4l2 and libcamera monitors components definitions
This was needlessly complicated and some of the requires did not make sense
2024-09-02 13:55:41 +03:00
George Kiagiadakis
219711129e main: show the profile name on the app name
Useful in multi-instance configurations
2024-08-29 17:15:50 +03:00
Julian Bouzas
0a86653085 autoswitch-bluetooth-profile: Use event source object managers
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.
2024-07-12 10:18:12 -04:00
Julian Bouzas
afcb91f59b rescan: Stop rescan for 2s if BT node is removed
The intention here is to fix a Bluetooth bug where changing between different
profiles momentarily causes streams to be linked to an internal speaker.
Unfortunately, this case is not handled by the event dispatcher because some
signals are emitted using idle callbacks, and therefore we have to rely on
extra logic in rescan.lua to solve the problem.
2024-07-01 08:12:33 -04:00
Julian Bouzas
ff33f38bea rescan: Merge filters metadata changed hook with rescan-trigger 2024-06-28 11:42:11 -04:00
Julian Bouzas
c60475b293 wpctl: Make sure default node Id is updated when printing filters
This will properly show '*' for default sink filters in the status output.
2024-06-28 15:13:34 +00:00