Commit graph

324 commits

Author SHA1 Message Date
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
George Kiagiadakis
73870c528b scripts: policy-node: use policy-config library 2023-04-17 07:48:18 -04:00
George Kiagiadakis
aafac752a1 scripts: remove policy-hooks.lua 2023-04-17 07:48:18 -04:00
George Kiagiadakis
6c27da6365 scripts/policy-desktop: add back the sample user hook on a separate file 2023-04-17 07:48:18 -04:00
George Kiagiadakis
2e3d2b2bb9 scripts/policy-desktop: fix the code of the find-target hooks to work again
* Use a common function to unwrap the objects out of the event
* Use the same common function to get the si flags
* Do not store back the si flags - there is no point in doing that,
  tables are objects in lua and they are passed around by reference
* Store the target on the event
2023-04-17 07:48:18 -04:00
George Kiagiadakis
013a61b440 scripts/lib: add policy-config script library 2023-04-17 07:48:18 -04:00
George Kiagiadakis
e5764e33a4 scripts: split policy-hooks into separate files, one for each hook 2023-04-17 07:48:18 -04:00
Julian Bouzas
6afca096e8 policy-device-profile.lua: use default rules if none are defined 2023-04-17 07:48:18 -04:00
Julian Bouzas
56087777f6 bluez.lua: use default rules if none are defined 2023-04-17 07:48:18 -04:00
Julian Bouzas
ed79e9a4d0 alsa.lua: use default rules if none are defined 2023-04-17 07:48:18 -04:00
Julian Bouzas
4bb949fd89 access-default.lua: use default rules if none are defined 2023-04-17 07:48:18 -04:00
Julian Bouzas
a8d6d50e2a config: use wireplumber nomenclature for the setting names 2023-04-17 07:48:18 -04:00
Julian Bouzas
6a612db57a config: make remaining non rule settings optional 2023-04-17 07:48:18 -04:00
Julian Bouzas
f1fbeaa661 m-lua-scripting: add fallback value for parse_{array|object}_safe() APIs 2023-04-17 07:48:18 -04:00
Julian Bouzas
d79d3e1465 policy-device-endpoint.lua: remove unused move configuration 2023-04-17 07:48:18 -04:00
Julian Bouzas
a23168af52 policy-hooks.lua: set move configuration to true by default 2023-04-17 07:48:18 -04:00
Julian Bouzas
048a975818 common-utils.lua: use different timeout callbacks for different states
This allows saving different states at the same time.
2023-04-17 07:48:18 -04:00
Ashok Sidipotu
f4382da5ba policy-hooks.lua: An example of user injectible hook 2023-04-17 07:48:18 -04:00
Ashok Sidipotu
bbe3b919d3 policy-{node|hooks}.lua: Fix issues in Zoom Desktop Video Sharing.
Fixes #339
2023-04-17 07:48:18 -04:00
Julian Bouzas
42fc17b234 config: clean and comment all configuration that is not needed by default
Most of the configuration settings have a default value when they are loaded by
the Lua scripts if they are not present, so we leave them commented in the
configuration. This will make the configuration smaller when supporting layered
configuration, as all the commented sections will be part of the override files.
2023-04-17 07:48:16 -04:00
Ashok Sidipotu
efb0c5a635 Wireplumber Settings: Port the latest changes from master
Port them from Lua config to JSON config.
2023-04-17 07:47:09 -04:00
Ashok Sidipotu
6762de3990 policy-{bluetooth|device-profile|device-routes}.lua: Optimize for Event stack
- Sharpen the hooks.
- Make settings live, apply them when they are changed.
- Move some of the common functions to common_utils.lua
2023-04-17 07:47:09 -04:00
Ashok Sidipotu
66c63a91a9 monitors: Align nomenclature of the settings and rules 2023-04-17 07:47:09 -04:00
Ashok Sidipotu
335fe69461 restore-stream.lua: optimize for event-stack
- Sharpen the hooks.
- Make settings live, apply them when they are changed.
- Move common funtions to common-utils.lua
2023-04-17 07:47:09 -04:00
Ashok Sidipotu
4dd8dd6ce5 policy-node.lua: apply policy settings live
Also change the setting names as per nomenclature.
2023-04-17 07:47:09 -04:00
Julian Bouzas
a512ddaaf3 scripts: use the WpSettings safe APIs
Avoids Lua errors if a setting cannot be parsed or does not exist.
2023-04-17 07:47:09 -04:00
Ashok Sidipotu
a5a6300662 policy-node.lua: fix the session items unhandling 2023-04-17 07:47:09 -04:00
Julian Bouzas
0983326433 scripts: use the new object ID as index in the Lua tables
We cannot guarantee that the object's bound-id is always valid when an event is
triggered, especially when an object is removed. This patch uses the new object
wireplumber unique ID to index Lua tables, fixing runtime WP_PROXY_FEATURE_BOUND
check warnings.
2023-04-17 07:47:09 -04:00
Ashok Sidipotu
72536261e9 policy-node.lua: Second round of cleanup.
- WirePlumber Lua now facilitates Lua libraries/modules, utilize this and create
  modules. Add some tests around this functionality.
- Create policy-hooks.lua containing all the hooks to find-target events
- Create policy-utils.lua module and push all the policy utility functions to it.
- Create common-utils.lua module and push the common utility functions to it.
- Remove all the above functionality from policy-node.lua and clean it up.
2023-04-17 07:47:09 -04:00
Ashok Sidipotu
3832e14c1c policy-node.lua: First round of cleanup
- remove scheduling rescan via core APIs instead use the event stack for proper
  scheduling.
- The rescan & handlelinkable hooks will push new findTargetSiAndLink events one
  per session item.
- Register a new "after-events-with-event" hook for findTargetSiAndLink event,
  it runs with lower priority than the rescan hook and so rescan hook can cancel
  unneeded findTargetSiAndLink events.
- Register hooks for move and follow properties.
2023-04-17 07:47:09 -04:00
Julian Bouzas
2f1aece8b6 settings: remove _get_{boolean|int|float|string}() APIs
They is really no needed with the new _get() API and the WpSpaJson API. In C,
users can use 'wp_spa_json_parse_{boolean|int|float|string}()' APIs to parse the
WpSpaJson. In Lua, users can just do 'Settings.get(setting, m):parse()'.
2023-04-17 07:47:09 -04:00
Julian Bouzas
5e6262718a monitors: use new Settings.get_all() API 2023-04-17 07:47:09 -04:00