Commit graph

998 commits

Author SHA1 Message Date
George Kiagiadakis
0fed249eb9 daemon: exit with WP_EXIT_CONFIG code if a component fails to load
This should be considered a configuration error: the user has
specified some component in the config file that cannot be loaded.
Changing the configuration file should fix it.
2023-04-17 07:48:18 -04:00
George Kiagiadakis
65c94c71fd daemon: check for the correct "file not found" code
When a script fails to load, the lua component loader returns
G_IO_ERROR / G_IO_ERROR_NOT_FOUND.
2023-04-17 07:48:18 -04:00
George Kiagiadakis
8219cc58c1 daemon: remove unused variable 2023-04-17 07:48:18 -04:00
Julian Bouzas
310232b810 meson: install scripts in /usr/share/wireplumber
Since the wireplumber configuration has been moved to /usr/share/pipewire, it
does not makes sense to have a different path for the WIREPLUMBER_CONFIG_DIR
environment variable. Therefore, the WIREPLUMBER_CONFIG_DIR environment variable
has been changed to just be an alias of PIPEWIRE_CONFIG_DIR. Finally, Lua
scripts are now installed under /usr/share/wireplumber/scripts instead of
/usr/share/pipewire/scripts as they are a wireplumber feature only.
2023-04-17 07:48:18 -04: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
Julian Bouzas
c61d1e4245 component-loader: make wp_core_load_component() API asynchronous
This change completely refactors the way components are loaded in wireplumber:
- The module_init() function must return a GObject now. This object is either
a WpPlugin or a WpSiFactory in the current modules.
- When the component loader initializes a module, it automatically registers
the WpPlugin or WpSiFactory with their respective methods. There is no need
to register the WpPlugin or WpSiFactory in the module now.
- The wp_core_load_component() API has been refactored to be asynchronows. This
allows the component loader to automatically activate WpPlugin objects, and
therefore allows the application to directly get the WpPlugin without having
to find it. This simplifies a lot of things.
- The 'ifexists' and 'nofail' component flags now work even if the respective
WpPlugin could not be activated.
- The code that loads components in main.c has also been simplified a lot,
and the option to load dangling components has also been removed.
2023-04-17 07:48:18 -04:00
George Kiagiadakis
7c2e713c9d m-metadata: remove module-metadata and replace it with a simple lua script 2023-04-17 07:48:18 -04:00
Ashok Sidipotu
de3214d21b default-node: rename select-default-nodes.lua
Consistent across linking and default node scripts.
2023-04-17 07:48:18 -04:00
Ashok Sidipotu
50377f2a70 default-nodes: make the default-config* keys trigger common
This trigger will be available all the time irrespective of whether persistant
option is enable or not.
2023-04-17 07:48:18 -04:00
Ashok Sidipotu
03bdf7d283 find-selected-default-node.lua: add a new default node hook
Hook accords higher priority to the currently selected device over and on top of
the previously selected devices.
2023-04-17 07:48:18 -04:00
Ashok Sidipotu
85db1e371e state-default-nodes: initialize the metadata variable 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
Ashok Sidipotu
137cbf3f22 wireplumber.conf: hike the priority of default-node scripts
default-node scripts need to run before metadata module as default nodes need to
act when the default metadata is created.
2023-04-17 07:48:18 -04:00
Ashok Sidipotu
000a869035 apply-default-node.lua: re-instate the "set default node" debug log msg 2023-04-17 07:48:18 -04:00
Ashok Sidipotu
82c8269381 prepare-link.lua: fix unassigned variables 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
fb855b00cf Rename endpoint concept to virtual session item 2023-04-17 07:48:18 -04:00
Julian Bouzas
9004362cda lib: remove WpEndpoint and WpSiEndpoint APIs 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
Julian Bouzas
6c6d5eccf9 main: use WpConf to get wireplumber component dependencies 2023-04-17 07:48:18 -04:00
Ashok Sidipotu
4b153ec553 link-target.lua: change into a async hook
link setup is a asynchronous action, async hook serves the purpose well
here.

The code dependent on links will be less error prone with this design.
2023-04-17 07:48:18 -04:00
Ashok Sidipotu
81c468cf23 find-best-routes.lua: add a null check while selecting routes 2023-04-17 07:48:18 -04:00
George Kiagiadakis
153c019343 m-std-event-source: separate rescan events for linking and default-nodes
Call the event "rescan-for-<context>", where <context> is either
"linking" or "default-nodes" and can be expanded in the future.

Add an additional hook in default-nodes to trigger the
rescan-for-default-nodes event when sources and sinks come and go.
2023-04-17 07:48:18 -04:00
George Kiagiadakis
dc196df239 m-std-event-source: fix state names in node-state-changed event
We need to use the enum nicknames ("idle"), not the enum names
("WP_NODE_STATE_IDLE"). This makes suspend-node work again.
2023-04-17 07:48:18 -04:00
George Kiagiadakis
26e47db4b4 scripts: default-nodes: fix mistakes to make default-node selection work 2023-04-17 07:48:18 -04:00
George Kiagiadakis
28548e0933 scripts: move create-item.lua under node/ and modernize it 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
652a6a6698 scripts: rename directories to follow the new naming scheme
* client: Logic that deals with configuring clients (basically, permissions)
* device: Anyhing that that deals with configuring devices (profiles, routes, ...)
* node: Anything that deals with node objects: configuring nodes, changing
  their state, their properties and also creating new nodes (but NOT linking them)
* linking: All the logic for creating links between nodes (and obviously,
  deciding which links to create)
* monitors: Scripts that deal with hardware subsystems, mainly monitoring
  hardware changes and reflecting them on pipewire
* default-nodes: All the logic for selecting the default sinks and sources
2023-04-17 07:48:18 -04:00
George Kiagiadakis
08a9d39295 events: rename find-target-si-and-link to select-target
And make sure it does not get prefixed with the subject type
2023-04-17 07:48:18 -04:00
George Kiagiadakis
d46d54f261 wireplumber.conf: update the list of loaded modules and scripts
A bit dirty for now, as the script auto-loading feature does not
work properly yet
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
85858c8a84 state-profile: dynamically respond to config.use-persistent-storage changes 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
9891758c70 remove policy-device-profile and m-default-profile 2023-04-17 07:48:18 -04:00
George Kiagiadakis
f99c3005f2 scripts: rewrite policy-device-profile and m-default-profile into a set of hooks
... excluding the persistent profile functionality for now (I am not convinced)
2023-04-17 07:48:18 -04:00
George Kiagiadakis
e1a8c3459a scripts: remove priority from all hooks and set up some basic dependencies 2023-04-17 07:48:18 -04:00
George Kiagiadakis
b100bdda4a event-hook: remove the exec type property & enumeration
With the latest changes, we can implement the "after-events" type
with external code that pushes a very low priority event that is
the "rescan" event.
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
54b14d1a29 scripts: port suspend-node.lua to the event dispatcher architecture 2023-04-17 07:48:18 -04:00
George Kiagiadakis
6668b40941 scripts: simplify policy-device-profile.lua 2023-04-17 07:48:18 -04:00
George Kiagiadakis
c2c95bf726 scripts: port misc hooks to use the new priority enumerations 2023-04-17 07:48:18 -04:00
George Kiagiadakis
374e4ecaff m-standard-event-source: simplify push_event, removing the subject_type
This avoids having to determine the subject type prior to pushing
an event from lua code and makes the call more convenient

Also add a debug statement to trace calls to push_event
2023-04-17 07:48:18 -04:00
George Kiagiadakis
5c113d2745 scripts: delete policy-node.lua
This has been split into smaller files in policy-desktop/
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
dd733df9c3 scripts/policy-desktop: add script for the filter-forward-format logic 2023-04-17 07:48:18 -04:00
George Kiagiadakis
6bc782d070 scripts/policy-desktop: add move & follow settings handlers 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