Commit graph

461 commits

Author SHA1 Message Date
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
Julian Bouzas
68c6fc2a38 filter-utils: always convert to string when checking if target rules match
This fixes the target not being found when setting non-string values in the
JSON matching rules of the 'filter.smart.target' property.
2024-01-22 10:15:16 +00:00
Julian Bouzas
caded6070d linking: remove redundant 'dont_move' parameter
The 'target.dont_move' property is only meant to be used with 'target.object'
metadata property, not smart filters metadata properties. This was probably
left accidentaly unused when designing a solution for #524 involving smart
filters.

Fixes #558
2024-01-19 13:29:02 -05:00
Sergio Costas
2ec202dfa1 client access: add support for snap permissions
This patch adds to wireplumber code to manage the Snap audio
permissions.

SNAP containers have two main "audio" rules:

 * audio-playback: the applications inside the container can
   send audio samples into a sink
 * audio-record: the applications inside the container can
   get audio samples from a source

Also, old SNAP containers had the "pulseaudio" rule, which just
exposed the pulseaudio socket directly, without limits. This
is similar to the current Flatpak audio permissions.

In the pulseaudio days, an specific pulseaudio module was used
that checked the permissions given to the application and
allowed or forbide access to the pulseaudio operations.
With the change to pipewire, this functionality must be
implemented in pipewire-pulse and wireplumber to guarantee
the sandbox security.

The current code checks for the presence of the pipewire.snap.id
property in a client, in which case it will read the
pipewire.snap.audio.playback and pipewire.snap.audio.record
properties, and allow or deny access to that client to
the nodes with Audio/Sink or Audio/Source media.class
property.

See !567 and pipewire!1779
2024-01-13 16:18:13 +00:00
Julian Bouzas
598b3c83ce filter-utils: handle new 'filter.smart.targetable' property
This property indicates whether the filter can be directly linked with clients
that have a defined target (Eg: pw-play --target <filter-name>) or not. This can
be useful when a client wants to be linked with a filter that is in the middle
of the chain in order to bypass the filters that are placed before the selected
one. If the property is not set, wireplumber will consider the filter not
targetable by default, meaning filters will never by bypassed by clients, and
clients will always be linked with the first filter in the chain.

Fixes #554
2024-01-11 10:54:41 -05:00
Julian Bouzas
cdeac07814 linking: handle defined target properly with smart filters
This patch fixes the policy to not link the client to the default filter if the
client's defined target is found, is not a filter, does not have any other
filters linked with it. In this case, the client is therefore linked to the
actual defined target. On the other hand, if the client's defined target is a
filter, the client is linked to the first filter in the chain that has the same
target as the defined filter's target.
2024-01-11 10:48:27 -05:00
Julian Bouzas
c37f95169d filter-utils: improve get_filter_from_target API to also work with filters 2024-01-11 10:34:13 -05:00
George Kiagiadakis
c5c5317599 state-routes: use the correct device id when restoring route properties
Fixes: #551
2024-01-08 12:28:21 +02:00
George Kiagiadakis
0b0595a156 apply-routes.lua: rename variable to make the code easier to understand 2024-01-08 12:28:21 +02:00
George Kiagiadakis
a7d0dacd12 state-routes: fix restoring volumes when a Route is changed manually
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
2024-01-08 12:21:27 +02:00
George Kiagiadakis
eb2d6efcd4 state: add save_after_timeout() method to replace all custom timeout code
This was a common pattern that we had in many places, so it makes sense
to consolidate it.
2024-01-04 16:38:33 +02:00
George Kiagiadakis
7fa16292c3 common-utils: remove the simple serializer functions that were used for state files 2024-01-04 10:38:23 +02:00
George Kiagiadakis
38b6eec456 state-routes: use json to store info in the state file 2024-01-04 10:27:02 +02:00
George Kiagiadakis
5d41ef2311 scripts: s/putils/lutils/g ("policy" utils -> "linking" utils) 2024-01-03 11:10:56 +02:00
George Kiagiadakis
c2d125b0da Merge branch 'master' into next 2023-12-23 18:34:00 +02:00
George Kiagiadakis
7dfc346a7b script docs: rewrite all csv-table to list-table for better source readability 2023-12-23 11:32:56 +02:00
George Kiagiadakis
c0b212bb0e scripts: common-utils: do not crash if the defaults table is nil
Fixes #542, #544
2023-12-18 10:56:30 +02:00
George Kiagiadakis
32b31232d1 docs: document components, profiles, features and settings 2023-12-14 16:49:12 +02:00
George Kiagiadakis
ca3bc3eb6d scripts: tidy up monitor settings and config options
* add a new common-utils method to get configuration sections with
  defaults more efficiently and with less boilerplate
* rework the ALSA reserve-device settings so that the priority is
  configured per device using rules and the application name comes
  from the WpCore instead of the config file
* rename bluetooth to bluez in all options for consistency with other
  monitors that use the backend API name
* rename alsa.midi to alsa-midi for consistency with bluez-midi
2023-12-09 15:52:24 +02:00
George Kiagiadakis
600adf003b scripts: tidy up device-related settings
* 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
2023-12-08 12:06:28 +02:00
George Kiagiadakis
e193ae0efc policy-endpoint-device: handle filters only if we have endpoints
Otherwise the filters are handled both in policy-node and here
and everything is messed up

Fixes: #536
2023-12-03 19:46:20 +02:00
Wim Taymans
a063d48281 scripts: pass is_filter to createLink
createLink uses an is_link variable that is unset. Fix this by passing
the is_link from the caller.
2023-11-29 11:01:34 +01:00
Wim Taymans
e9fc965b32 scripts: log si_link after creating it
Or else we get a exception because it is nil.
2023-11-29 11:00:08 +01:00
George Kiagiadakis
0ac2947aed scripts: add new sm-objects script
This allows loading objects on demand by adding entries on the
"sm-objects" metadata object.

It is useful to dynamically load pipewire modules such as loopbacks
or network modules without having to start a new pipewire process with
a hardcoded config file.

It is also useful to load new metadata objects in order to implement
the singleton metatada concept as discussed in pipewire!1742

This may be expanded in the future to be able to load other types of
objects.

The key name, combined with the subject, is considered a unique id for
this instance of the object. The value should be a json object with
a 'type' specifying the type of object, together with a 'name' and 'args'
2023-11-22 08:38:36 +00:00
Ashok Sidipotu
256f60ebf2 policy-device-profile.lua: add a method to prioritize BT codecs. 2023-11-22 08:32:28 +00:00
Ashok Sidipotu
a87d0478ea policy-endpoint-device.lua: connect filter output to actual sinks
The device script will also scan for the filter output streams and
connect them to the actual sink devices.
2023-11-22 08:22:59 +00:00
Ashok Sidipotu
9f6066ea0d policy-endpoint-device.lua: logic to connect endpoint to filter
While handling endpoints, first check to see if there is a filter
intending to connect to it.
Also prevent Endpoints connecting to filters unless otherwise
configured.
2023-11-22 08:22:59 +00:00
Ashok Sidipotu
83e990bf2d policy-endpoint-device.lua: enhance link log msgs 2023-11-22 08:22:59 +00:00
Ashok Sidipotu
eba3d9d6f8 policy-endpoint-client.lua: avoid connecting filters to endpoints
Equalizer Node or filter nodes are considered as regular linkable and
its output is connected to endpoint. Prevent this by skipping over
filter nodes in this script.
2023-11-22 08:22:59 +00:00
George Kiagiadakis
0a7bd4fe86 si-standard-link: remove the "passive" property
PipeWire no longer uses the link.passive property, so there's no
point in adding it here. The node.passive property is used directly.
2023-11-20 12:00:54 +02:00
George Kiagiadakis
5b1ff7377f si-audio-endpoint: mark the nodes as passive instead of marking the links
This is a behavioural change in effect since pipewire 0.3.68, where
pipewire's link-factory ignores the link.passive property and the
node.pasive = in/out/true is used instead.
2023-11-20 11:56:07 +02:00
George Kiagiadakis
383b0e605d scripts: tidy-up linking related settings
* prefix all settings with just "linking."
* rename settings to make more sense
* fix the handling of the "follow" setting
* move the "move" handler to the rescan.lua script, as it's just a rescan hook
2023-11-19 18:34:33 +02:00
George Kiagiadakis
33fc476cb3 s-linking: always rescan when the default targets change
The "follow" setting was never really meant to disable reacting to
default target changes. It is also not meant to disable moving normal streams
to follow the default target. It is only meant to control whether streams
with a 'target.object' that matches the default target will move or not
to follow the default target changes (PulseAudio compat thing...)

Even if we leave this code here, disabling the "follow" option may disable
reacting to default target changes, but the streams will be moved anyway
when there is some other change in the graph (i.e. in the next rescan)
2023-11-19 17:52:20 +02:00
George Kiagiadakis
679d660058 settings: tidy up node-related settings
* prefix all settings with "node."
* move settings-stream.lua to settings-node.lua
* move the "audio-no-dsp" setting to the node settings
* add more settings related to node features
* split the default stream volume into 2 settings, one for playback
  streams and one for capture streams
2023-11-15 18:16:52 +02:00
George Kiagiadakis
2f071a67be scripts: rename all foo-config libs to settings-foo
And also use the term 'settings' everywhere instead of 'config' to refer
to the options managed by the WpSettings architecture
2023-11-15 15:44:01 +02:00
George Kiagiadakis
460e714a10 access-default: do not crash if the rules section is not defined in the config 2023-11-15 15:44:01 +02:00
George Kiagiadakis
ab44996ce9 access-default: do not require the configuration file rules to operate 2023-11-15 13:37:33 +02:00