Commit graph

512 commits

Author SHA1 Message Date
Ashok Sidipotu
fcaece85e9 linking-utils: add routines to keep track of the priority media role link 2024-06-26 15:48:07 +03:00
Ashok Sidipotu
375094151d linking: get-filter-from-target.lua: bypass for media role targets 2024-06-26 10:16:10 +03:00
Ashok Sidipotu
4dd831424a linking: add a new hook to find media role targets 2024-06-26 10:16:10 +03:00
Julian Bouzas
4868b3c336 get-filter-from-target: Don't bypass the hook if the session item is a regular filter
Regular filters should be treated as regular stream / device nodes. Note that
the filter utils API is meant to be used using the direction of the main smart
filter nodes. This is why we use the target direction instead of the actual
stream direction to check if the stream session item is smart or not.
2024-06-25 14:15:46 -04:00
Julian Bouzas
fa67121665 filter-utils: Allow smart filters to have as target filters that are not smart
Filters that are not smart should be treated as regular client/device nodes,
therfore, smart filters should be able to use them as a target.
2024-06-25 14:05:43 -04:00
George Kiagiadakis
47ec81408e scripts/device: avoid crashing if the device.name is not set
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
2024-06-17 09:13:16 +03:00
Julian Bouzas
2353a0991b autoswitch-bluetooth-profile: Always destroy the restore timeout source before switching
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.
2024-06-12 16:27:19 -04:00
James Calligeros
f57a46308d node/software-dsp: ensure that filter chains are properly unloaded
Indexing into the subject from a node-removed event is slightly quirky.
As a result, we were not properly freeing filter chains tied to
disconnected nodes.

Change how we store the list of loaded filters and ensure they
are properly freed when their parent node is removed from the graph.

Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
2024-06-10 11:31:50 +00:00
Julian Bouzas
eb707096f7 scripts: Fix autoswitch BT profile when using filters
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.
2024-06-06 17:05:18 -04:00
Julian Bouzas
789b526c61 bluez: Don't create loopback source if autoswitch setting is disabled 2024-06-06 17:00:46 -04:00
George Kiagiadakis
e6eed2dfb0 monitors/alsa: add some logging around node name deduplication 2024-05-31 17:03:33 +03:00
George Kiagiadakis
e3e8c9cdcb device/state-profile: do not restore unavailable profiles from the state file
Fixes: #613
2024-05-31 12:14:19 +03:00
George Kiagiadakis
9b4628455c node/create-item: simplify si properties configuration
Copy all the node properties into the session item and customize
afterwards, instead of starting with an empty set and cherry-picking
properties... We need to cherry-pick more and more properties
overtime and it's easy to make mistakes
2024-05-24 20:41:16 +03:00
George Kiagiadakis
df8bc12464 state-stream: fix using the default volume
When there was no previous state stored, the default volume was
also not applied because the code would return from the hook early

Fixes: #655
2024-05-24 20:36:28 +03:00
Julian Bouzas
b40ba825c2 filter-utils.lua: Check media type when finding the default filter
This avoids wireplumber trying to link a video stream node with the default
audio smart filter if smart audio filters are configured.
2024-05-24 07:33:21 -04:00
George Kiagiadakis
226be2e2b2 monitor-utils: fix variable check
See !636
2024-05-23 12:59:46 +03:00
George Kiagiadakis
2811d46a38 monitor-utils: make cam_api_data a local variable
Otherwise it is global and it retains a reference to the `parent`
WpSpaDevice object until this function is called again, which prevents
some camera nodes - in some cases - from being destroyed

Fixes #640
2024-05-23 12:35:23 +03:00
Barnabás Pőcze
4ed51791e0 linking: return after aborting transition
Avoid calling return_error() on the same transition multiple times.

Fixes: 4b153ec553 ("link-target.lua: change into a async hook")
See #628
2024-05-18 01:36:39 +02:00
Ashok Sidipotu
06e11dc4be monitors/camera: fix camera device deduplication not working for certain devices.
Enhance the parsing logic to consider more than one device number. libcamera
devices some times use up multiple V4L2 devices, in this case libcamera should
be given a chance to enumerate the device.

Fixes #623
2024-05-08 14:20:16 +00:00
Julian Bouzas
0bd64f17af filter-utils: Check main filter nodes in a more robust way
This patch makes the check more robust when detecting main filter nodes. This is
because some filters might append '/Internal' to their main node media class.
The direction check has also been improved to work with Video filters.
2024-05-02 12:26:55 -04:00
Pauli Virtanen
42370f0547 scripts: fix event:get_data() usage in apply-profile
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.
2024-04-27 17:48:16 +03:00
George Kiagiadakis
e4f9fb824e default-nodes: fallback to priority.driver if priority.session is not set
See #642
2024-04-22 11:39:45 +03:00
James Calligeros
1844fd6d61
Revert "node/software-dsp: do not hide target node when hide-parent is false"
Using parseBool is actually more broken if the property is already parsed as a
boolean, and causes the node to remain unhidden even when hide-parent = true.

Revert 2a45842169 to fix this behaviour.

Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
2024-04-17 18:31:09 +10:00
James Calligeros
d89293b606
node/software-dsp: implement loading filter graphs from disk
Using the new Conf() constructor, we can load and parse a filter graph
from a file on disk. This is useful when, for example, maintaining a
large database of filter graphs. It also keeps wireplumber.conf.d free
from clutter.

Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
2024-04-17 18:31:09 +10:00
Pauli Virtanen
9d7c6b85d0 monitors/bluez: fix BAP device set node naming
It is intended that its name is the actual device node name.
Fix this, as it was broken in some recent changes.
2024-04-06 21:59:16 +03:00
George Kiagiadakis
8ee351838d monitor-utils: clear cam data after creating nodes
The cam_data structure stores a reference to the "parent" WpSpaDevice
and doesn't allow it to be destroyed when the monitor detects that
the device is no longer present. Clear it right after pushing the event
to make sure there's no dangling reference left around

Fixes: #627
2024-04-03 12:31:42 +00:00
George Kiagiadakis
3b0c0fcd7e state-stream: fix storing/restoring notification volume
We apparently store things in the <media-class>:<key>:<value>
format, while pipewire-pulse expects <media-class>.<key>:<value>
and this detail was missed in the latest refactoring.

It also seems that I forgot to ensure that restoring this metadata
key worked. The hook was there, but not registered.
Remove the hook and directly populate the metadata object when
it is activated, as it seems simpler.

Fixes: #604
2024-03-30 11:53:45 +02:00
James Calligeros
2a45842169
node/software-dsp: do not hide target node when hide-parent is false
The existence of props["hide-parent"] is truthy. Parse the boolean explicitly
to get the correct logic.

Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
2024-03-30 00:00:57 +10:00
James Calligeros
82b0ec8c30
node/software-dsp: Port Node ObjectManager to SimpleEventHook
Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
2024-03-29 23:48:09 +10:00
James Calligeros
9ab7c024f8
node/software-dsp: get match rules from conf.d
This allows DSP rules to be specified in a wireplumber.conf.d file under
the node.software-dsp.rules section. Properties are specified in the
software-dsp action.

Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
2024-03-29 23:46:54 +10:00
James Calligeros
d5217fd4b6
node/software-dsp: move and rename scripts/policy-dsp.lua
As this DSP "policy" is intended to run on the creation/deletion
of a node, move it into the node subdir.

Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
2024-03-29 22:44:53 +10:00
James Calligeros
62dd6effa8
policy-dsp: allow matching on all node properties
Prevously, we were only looking at node["global-properties"] for
properties to match on. Change this to instead run against
node.properties, so that we can use type-specific properties such as alsa.id.

Signed-off-by: James Calligeros <jcalligeros99@gmail.com>
2024-03-26 19:14:05 +10:00
Robert Mader
3ffd0956d4 linking: Use sendClientError in link-error handler
The current code was not updated to use `clients_om`, thus never
found a client, ending up never sending client errors.
Just use the shared helper to avoid such issues in the future.
2024-03-25 14:56:30 +01:00
Robert Mader
94031f8ef9 scripts: add error code argument to sendClientError helper
And update all users accordingly. This will allow the following commit
to use the helper with a different error code.
2024-03-25 14:56:04 +01:00
George Kiagiadakis
c89316e52c linking: improve link failure & debug messages 2024-03-25 09:55:13 +02:00
George Kiagiadakis
ccfc501e82 docs: move well-known settings docs from src/scripts/lib to where they belong
These were documented in src/scripts/lib initially because the settings-manager
scripts used to be also there and it made sense to keep them close together.
2024-03-23 16:49:13 +02:00
Pauli Virtanen
61d1398f5b autoswitch-bluetooth-profile: never use headset profile without input
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.
2024-03-23 14:02:21 +02:00
Pauli Virtanen
a73c931723 monitors/bluez: fix autoswitch A2DP input profiles
Profile autoswitch should support also A2DP profiles with input route,
so the loopback should not assume the source node is SCO one.

Also fix handling of AG SCO output stream nodes, which should not be
hidden as internal.
2024-03-23 14:02:21 +02:00
Pauli Virtanen
428462ddf3 filter-utils: fix handling of targetless smart filters
A smart filter should be considered "targetless" (i.e. interpose on
streams going to default target) only if filter.smart.target is not set.

Currently any smart filter with specified target not found is considered
such, which is wrong.  This causes misbehavior, such as all recording
streams going to the bluetooth dummy source.

Fix this by doing it correctly.
2024-03-21 20:19:26 +02:00
George Kiagiadakis
a79d002402 alsa: rename vm.type to cpu.vm.name to be consistent with pipewire master
See 7e9e261fa6
2024-03-18 17:03:44 +02:00
Julian Bouzas
f6fede9ee4 monitors/bluez: add 'internal' prefix to internal bluez node names.
And name the loopback source node the same as bluez source without 'internal'
prefix. This keeps consistency with input/output node names when switching
bluetooth profiles.
2024-03-11 13:49:01 -04:00
Julian Bouzas
5f9b3a9659 monitor/bluez: set node.name property when creating combine stream 2024-03-11 13:41:23 -04:00
Julian Bouzas
5e19722491 scripts: fix regression in state-routes.lua when marking routes as 'active'
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.
2024-03-11 09:47:31 +00:00
Julian Bouzas
bed3b62e0d scripts: improve linking logs 2024-03-11 09:47:31 +00:00
Ashok Sidipotu
88f893e2ce monitors: use parseBool for boolean properties in rules
The boolean values of properties in rules are strings in JSON config files and
they will retain the same type when they are translated to Lua.
Use cutils.parseBool() function when they have to be interpreted as bools.

Fixes: #586
2024-03-11 07:19:27 +00:00
Julian Bouzas
d0f16e4757 scripts: make sure target is not nil when iterating filters with matching targets 2024-03-08 10:56:34 -05:00
Julian Bouzas
22de7513c1 scripts: rescan linkables when device EnumRoute param changes
This is needed for some devices that expose both Headset and Speaker nodes, so
that the applications are automatically linked to the Headset node or Speakers
node automatically when plugging and unplugging a headset.
2024-03-06 10:46:50 -05:00
Julian Bouzas
e496222a03 scripts: fix available routes check when selecting the default node
Also reevaluates default nodes when the device params changed.
2024-03-06 10:46:50 -05:00
George Kiagiadakis
a141ec0c68 scripts: fix typo in rescan-virtual-links.lua 2024-03-05 16:34:11 +02:00
George Kiagiadakis
6321ff9f62 scripts: access: cache the access.rules in a global config variable 2024-03-04 16:33:14 +00:00