Commit graph

58 commits

Author SHA1 Message Date
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
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
c37f95169d filter-utils: improve get_filter_from_target API to also work with filters 2024-01-11 10:34:13 -05: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
5d41ef2311 scripts: s/putils/lutils/g ("policy" utils -> "linking" utils) 2024-01-03 11:10: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
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
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
cb243eea6d common-utils: avoid crashing when a rules section is not defined in the config 2023-11-15 12:57:41 +02:00
George Kiagiadakis
299e671ffa scripts: switch to using JsonUtils.match_rules_apply_properties()
Note: this requires all existing config files to be modified to follow
pipewire's rules syntax, with an "actions" object wrapping the
"update-props" object.
2023-11-07 16:36:49 +02:00
Julian Bouzas
8ac96f4a37 linking: handle 'target.linger' property
When set to 'true', the node will remain alive without any error produced if
it cannot be linked to its specified target; in all other cases, an error will
be produced and the node will be destroyed.
2023-11-02 16:09:48 +00:00
Julian Bouzas
970050d3b5 linking: handle 'target.dont-fallback' and 'target.dont-move' properties
Two new properties are available to change the behavior of the linking policy:
 - target.dont-fallback: when set to true, the node shouldn't be allowed to
fallback to another available target other than the one specified in the
target.object property or metadata.
 - target.dont-move: when set to true, wireplumber should ignore the
target.object metadata, so that it isn't possible to dynamically move the node
to another target using metadata.

See #524
2023-11-02 16:09:48 +00:00
Julian Bouzas
c9dc02d941 rescan: make sure disabled smart filters are unlinked before rescanning
This patch improves the smart filters unlinking logic by only unlinking smart
filters that are disabled, instead of any kind of filters. The patch also
removes redundant filter hooks.
2023-10-26 08:15:09 -04:00
Julian Bouzas
6980f9ff5d filter-utils: always evaluate filters before 'linking/rescan' hook
Fixes smart filters not being linked correctly when starting wireplumber if no
clients are playing/capturing audio.
2023-10-25 10:34:40 -04:00
Julian Bouzas
388acb6ff3 scripts: Fix bluetooth profile autoswitch
This patch updates the deprecated policy-bluetooth.lua script so that it works
with the current version. The script has been moved into the device sub-folder,
and renamed to autoswitch-blueooth-profile.lua. The settings-manager is also
used for the configuration, and the actual configuration has been moved from
linkind.conf to bluetooth.conf.
2023-10-19 11:24:42 -04:00
Julian Bouzas
4ad263b16c scripts: add new 'filter.smart' property
This allows users to enable/disable smart filter policy per filter. The property
is considered false by default, meaning that smart filter policy is disabled for
all filters by default.
2023-10-02 10:44:46 -04:00
Julian Bouzas
7044226f66 scripts: use 'filter.smart' prefix for smart filter properties 2023-10-02 10:44:46 -04:00
Julian Bouzas
0b44d9cf84 scripts: change filter.enabled property to filter.disabled
Avoids confusion with default value if the property is not defined.
2023-10-02 10:44:38 -04:00
George Kiagiadakis
1e40108d94 linking-utils: rename unwrap_find_target_event -> unwrap_select_target_event 2023-09-30 12:06:40 +03:00
George Kiagiadakis
c7b00599d7 scripts: remove 'active-features' session item constraints
I don't fully remember where this originates from, but it looks like
some sort of hack to workaround a race condition where the event handler
would try to iterate over items that were just created and were not yet
fully ready to be used.
2023-09-30 11:10:30 +03:00
George Kiagiadakis
6af88b283c linking-utils: cleanup duplicate functions 2023-09-30 11:02:02 +03:00
Ashok Sidipotu
1f92767d4b config: replace "policy" with "linking" 2023-09-26 10:07:57 +03:00
Julian Bouzas
06fa06ca5c scripts: fix minor issues with smart filters policy
The filter's destination target was not being found properly due to iterating
the matching rules table with ipairs instead of pairs... the later is meant to
be used with JSON objects. In addition, the filters were not being re-evaluated
and linked properly when a device node was removed, this is because of a typo in
the find-best-target.lua script.

See #501
2023-09-21 09:04:31 -04:00
Julian Bouzas
1ba3844f2c scripts: add filter-utils.lua
Utilities Lua script for the policy to easily handle filter nodes.
2023-09-03 14:33:34 +00:00
Julian Bouzas
d383762812 device: remove echo-cancel configuration
This will be possible to do with the new filter-utils.lua design.
2023-09-03 14:33:34 +00:00
Ashok Sidipotu
591d0b4370 camera-monitors: add a config property for camera discovery timeout 2023-08-15 07:14:59 +00:00
Ashok Sidipotu
359ea7b17d monitor-utils: use uniform naming style for lib apis 2023-08-15 07:14:59 +00:00
Ashok Sidipotu
426e1bbffe camera monitors: introduce cam device arbitration logic 2023-08-15 07:14:59 +00:00
Ashok Sidipotu
6596d71c4f monitor-utils: introduce monitor utils lua library 2023-08-15 07:14:59 +00:00
Ashok Sidipotu
5c17747112 policy-utils.lua: remove object managers 2023-04-17 07:48:18 -04:00
Ashok Sidipotu
80554fe1c7 common-utils.lua: remove metadata object managers 2023-04-17 07:48:18 -04:00
Ashok Sidipotu
0d73c34c68 common-utils: add a null check for default-nodes query
common-utils is a singleton common resource, it cannot depend on the order in
which the components are loaded.
2023-04-17 07:48:18 -04:00
Julian Bouzas
d2123827f7 scripts: use the event stack to handle virtual session items
This removes both the policy-virtual-client.lua and policy-virtual-device.lua
scripts, and creates a new linking/find-virtual-target.lua script to link
clients with virtual session items if one of them can be found. In addition to
this, this patch also ports the policy-virtual-client-links.lua into a new
scripts/rescan-virtual-links.lua to use the event stack. The idea is for the
scripts/link-target.lua to create all links but only activate non virtual links,
and for the scripts/rescan-virtual-links.lua to activate/deactivate virtual
links based on role priorities.
2023-04-17 07:48:18 -04:00
Julian Bouzas
360e0b3eaf scripts: use WpConf API to get configuration values
This patch also moves nested configuration objects that are not considered
settings from the wireplumber.settings section to its own configuration
section (eg the rules array, the spa plugin properties, etc...). This allows
those objects to be merged with other same sections defined in other files.
2023-04-17 07:48:18 -04:00
George Kiagiadakis
258d9f32e1 scripts: rename all hooks to follow a nicer naming scheme
Use the directory name and file name to construct the hook's name,
like a path. This way, when you see a hook name, it is clear where
to find that hook in the source code.
2023-04-17 07:48:18 -04:00
George Kiagiadakis
2325178d5c default-nodes: port to a set of scripts with hooks 2023-04-17 07:48:18 -04:00
George Kiagiadakis
d8e461940f scripts: refactor restore-stream into node/state-stream
* Use more hooks and no custom object managers
* Use the settings manager for the config values
* Allow fully disabling the hooks when both restore-props and restore-target
  are disabled in the settings
* Change the format AND the name of the state file; use json directly
  in the values now that we can
2023-04-17 07:48:18 -04:00
George Kiagiadakis
b5d8a7982f scripts: split/refactor the policy-device-routes script into smaller hooks 2023-04-17 07:48:18 -04:00
George Kiagiadakis
bcb4e80723 m-std-event-source: use type-specific event names and multiple object managers
It is better to have type-specific event names to minimize the amount
of constraint string matches we do on hooks, as most hooks (if not all)
are interested on specific types of objects only.

Similarly, use a different object manager for each object type to
minimize the performance impact of iterations and lookups, as all
such actions are interested in only 1 object type every time.

Port all existing hooks to the new event names and the get-object-manager API.
2023-04-17 07:48:18 -04:00
George Kiagiadakis
993a2686f6 scripts/policy-desktop: add main rescan script 2023-04-17 07:48:18 -04:00
George Kiagiadakis
67ab0eced2 scripts/lib: update policy-config to use the settings manager 2023-04-17 07:48:18 -04:00
George Kiagiadakis
57d4a8cb07 scripts/lib: add a new settings manager lua library
This intends to reduce the amount of code needed to maintain
tables of settings values across different scripts
2023-04-17 07:48:18 -04:00
George Kiagiadakis
73870c528b scripts: policy-node: use policy-config library 2023-04-17 07:48:18 -04:00