Commit graph

497 commits

Author SHA1 Message Date
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
George Kiagiadakis
655a24acf0 scripts: remove cutils.evaluateRulesApplyProperties()
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.
2024-03-04 16:33:14 +00:00
George Kiagiadakis
3fbf1286e6 lua: change the Conf API to have methods for getting sections as specific types
In some cases we need to get a section as JSON, so that we can pass it
down to the rules parser, while in other cases we neeed to get it as a
table to use it natively, and in that case we even need to differentiate
between it being an object, an array or an object with WpProperties.

Make it also possible to optionally pass tables with default values to
the functions so that we can get rid of cutils.get_config_section()
as well.
2024-03-04 16:33:14 +00:00
Julian Bouzas
8935837cda scripts: remove settings-manager and use the Settings API
The settings manager is not needed anymore because the WpSettings Lua API
returns now the default value from the schema if the setting is not found.
2024-02-28 10:20:31 -05:00
Ashok Sidipotu
89b9218031 device-profile-hooks: add a hook to prioritize the profiles 2024-02-12 13:15:02 +05:30
Ashok Sidipotu
112a45a230 device-profile-hooks: move the selected profile check
move the check to the beginning of the hook.
2024-02-12 13:15:02 +05:30
George Kiagiadakis
4d33aff107 monitors: improve notice messages about missing SPA plugins 2024-02-10 11:44:19 +02:00
Stefan Ursella
ac508aef57 linking: handle 'node.linger' property when target node not known
Do not send an error to the client when the target is not defined
and the 'node.linger' property is set.

It is not absolutely necessary that every node has a defined target.

We can have a 'Stream/Output/*' node which can be linked to
multiple 'Stream/Input/*' nodes and only the 'Stream/Input/*'
nodes have a defined target.
2024-02-04 17:33:46 +01:00
Julian Bouzas
b3a71e3f1c linking: rename props to 'node.dont-fallback', 'node.dont-move' and 'node.linger'
This makes those properties more consistent with 'node.dont-reconnect'.
2024-02-02 11:15:31 +00:00
Julian Bouzas
d01441ca0a scripts: move filter-forward-format.lua from 'linking' to 'node' subdirectory
This is because 'filter-forward-format.lua' only configures nodes, and therefore
does not have anything to do with the linking logic. The setting has also been
renamed to 'node.filter.forward-format'.
2024-02-01 10:00:22 -05:00
Pauli Virtanen
6d9205cfe0 filter-utils: fix indexing nil value
Check target is not nil, which sometimes occurs, before trying to access
its .id property.

Fixes lua errors in logs.
2024-01-31 09:04:54 +00:00
George Kiagiadakis
c6e3dbf887 scripts/linking/rescan.lua: fix log access
The log object should be used with : in order to make sure that the
log handler has the correct topic in context.
2024-01-31 11:00:37 +02:00
Julian Bouzas
5581a9c2b7 scripts: only log session item Id when unhandling it
This is because the associated node does not exist anymore. This change also
logs the session item Id when handling it, so that it is easy to know if the
unhandled session item was handled or not.
2024-01-30 11:51:17 -05:00
Julian Bouzas
9cdb8f3110 bluez.lua: always hide sco-source nodes from applications
Since the loopback bluetooth source node is meant to be always used by
applications, this change hides the actual bluez sco-source node by marking
them as internal. This avoids showing 2 input devices in pavucontrol per BT
device if HSP/HFP profile is enabled.
2024-01-29 12:11:45 -05:00
Julian Bouzas
95ae88d3e7 bluez.lua: set the loopback input stream media class to internal
This hides the loopback stream node from applications, making desktop
environments to not show the 'recording from microphone' icon (Eg gnome-panel)
when the bluetooth device is not recording yet.
2024-01-23 11:59:57 -05:00
Julian Bouzas
874a432c69 autoswitch-bluetooth-profile: remove applications array and use loopback filter
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.
2024-01-22 10:15:16 +00:00