Commit graph

740 commits

Author SHA1 Message Date
George Kiagiadakis
60c5982cd0 lua: add bindings for event / hook / dispatcher 2023-04-17 07:47:09 -04:00
Ashok Sidipotu
cfd51d9fe2 lib: wpsettings: Add _register_callback () API 2023-04-17 07:44:19 -04:00
Ashok Sidipotu
3011a1c07e m-settings: Fix the crash with empty settings
Add a null check when iterator gets the value to detect the end of the
JSON object, this will ensure the rest of the code that operates on the
value is bypassed.

Still it must be noted that an empty setting screws up the following
settings and behavior is undefined, this is the limiation in the
spa-json parsing.
2023-04-17 07:44:19 -04:00
Ashok Sidipotu
2f60077460 endpoints: Switch endpoints config to JSON
- Move the endpoints defination to wireplumber.conf under a new section
  in the form of two JSON objects, namely endpoints and
  endpoints-roles.
- Treat the endpoint objects as settings, for the sake of loading,
  parsing and querying.
- m-settings loads the objects and WpSettings parses them as any other
  settings.
- Make the following changes in endpoint scripts.
   - Get the endpoint settings using the _get_string() API.
   - Parse and use the data.
   - Remove references to the config/lua
- Remove the endpoints defination in config/lua
2023-04-17 07:44:19 -04:00
Ashok Sidipotu
e180ff2f94 device-settings: Switch device settings to wpsettings
- move all the device based settings and scripts to JSON config and
  remove config/lua references.
2023-04-17 07:44:19 -04:00
Ashok Sidipotu
3a25bc14d2 lib: Add _get_float() wpsettings API
- also add the corresponding C & Lua tests.
2023-04-17 07:44:19 -04:00
Ashok Sidipotu
b76baca520 wireplumber.conf: split up the wireplumber config
- create wireplumber.conf.d and create a file each for a group
  of settings.
- distrube the "wireplumber.components" section as well into these
  files
2023-04-17 07:44:19 -04:00
George Kiagiadakis
893e44c51e lua: fix number of returned values in Settings.apply_rule 2023-04-17 07:44:19 -04:00
Ashok Sidipotu
7d304096e5 lib: Add _get_{int,string}() APIs
- add integer and string version of the APIs,
- Also Refine the APIs, return value to indicate the setting existance
  and a new param to return the value of the setting.
- add their lua bindings as well, in lua binding the return value nil
  indicates that the setting is not defnied.
- Add corresponding C and lua tests as well.
- Add a few handy debug msgs.
2023-04-17 07:44:19 -04:00
Ashok Sidipotu
a4f16a98f0 main: Add support for deps flag in loading modules
- support loading modules dependent on wireplumber settings in JSON
  config.
- load the settings module before parsing wireplumber.components,
  so that dependencies can be fetched during parsing.
- access lua scripts are switched to JSON based config and lua configs
  are removed.
2023-04-17 07:44:19 -04:00
Ashok Sidipotu
a5d62b7bbd lib: Add wp_settings_apply_rule() API
- add C based tests
- add lua binding for the API and corresponding lua tests
- address comments from previous commits
2023-04-17 07:44:19 -04:00
Ashok Sidipotu
4d7ce2292e tests: Add tests for WpSettings object
- settings.c tests conf file loading & parsing, metadata updates,
  wpsetttings object creation and its API.
- settings.lua tests the API from lua scripts.
- Add a sample settings.conf file, this file contains sections copied
  over from client.conf along with the settings section. Add a file
  each for wp side and lua side of scripts.
- Make changes in base test infrastructure to take a custom conf file.
- Enhance the wp_settings_get_instance_api() to be take metadata_name
  parameter. So, Wpsetttings is now a singleton instance for a given
  metadata file.
- Enhance the m-settings module also to be take metadata_name parameter.
  this is handy for lua side of tests as its cumbersome to do this is
  lua.
2023-04-17 07:44:19 -04:00
Ashok Sidipotu
8fd8b01b7a lib: Introduce WpSettings API
- WpSettings is a singleton object which attaches itself to the core
  and registry, it provides a get_instance () for its clients.
- WpSettings provides API to get/set wireplumber settings and rules.
- main.c loads the new object and makes sure it is available for
  for all the modules and scripts. This is achieved by introducing
  a new activation step.
- Add the lua bindings for get_setting API.
2023-04-17 07:44:19 -04:00
Ashok Sidipotu
e9391b195f m-settings: Module to handle JSON config settings.
- parse settings from .conf file.
- create "sm-settings" metadata and copy settings as key value pairs
  to it.
- put in place "persistent" behavior, control it with a special
  setting.
- when persistent behavior is enabled.

  - create a state file and update settings to it.
  - monitor changes in the metadata and update the settings to state
    file.
2023-04-17 07:44:19 -04:00
Robert Mader
04bf9b013e m-si-link: propagate WpLink errors
Add a new signal that gets emitted if any WpLink changes to an error
state. This allows better error handling in cases where e.g. no format
could be negotiated.
2023-02-16 10:39:31 +00:00
Julian Bouzas
c8be8d91be m-lua-scripting: increase refcount of export_core before pushing into the Lua state 2023-02-10 10:54:52 -05:00
Julian Bouzas
6b761c03e1 m-lua-scripting: ignore string/integer table keys when constructing a JSON Array/Object 2023-01-04 11:20:14 -05:00
Dylan Aïssi
5d9fb9f678 Fix typo: numner to number 2022-12-14 10:51:52 +01:00
Carlos Rafael Giani
784f03d57a module-si-audio-adapter: Pass through encoded audio 2022-12-07 15:18:25 +00:00
Sanchayan Maity
217f2babdf module-si-audio-adapter: Do not set channels if parsed result is 0 2022-12-07 15:18:25 +00:00
Pauli Virtanen
7a1b48b741 module-default-nodes: prioritize previous configured defaults
The node priorities are difficult to configure for users, and are
not necessarily meaningful for them.

When there is no configured default node, or the configured default node
does not exist, prioritize previously configured default nodes over the
automatic node priorities.

Keep track of a stack of previous configured nodes, and update the stack
when the configured node changes.
2022-09-27 18:53:45 +03:00
Julian Bouzas
ab6bc62c88 m-portal-permissionstore: remove old unused header
Missed change from commit 2c53486e
2022-09-15 09:06:44 -04:00
Pauli Virtanen
370b692933 m-si-link: don't wait for establish before activation + cleanup links
SiLink should not wait for WpLinks becoming ESTABLISHED, before
activation. That flag shows whether a link has moved away from the
"init" state, however, links to e.g. Pulseaudio corked streams can stay
in "init" state until uncorking.  This causes trouble for policies,
which needlessly wait for such links to establish.

The WpLink objects may also be kept alive by other referents, and
just unrefing them does not necessarily destroy the PW objects.

Activate SiLink even if the WpLink is still in "init" state. It's enough
that the link otherwise successfully establishes.

At dispose time, explicitly request destroying the WpLinks that were
created by the SiLink, to ensure they are removed even if there's
something else referring to them.
2022-08-14 19:47:11 +00:00
Fabian Vogt
d5029697de Fix leftover use of module-reserve-device's state property
The move to the WpDbus API dropped the "state" property from the plugin,
but left the property enum and use of it in alsa.lua. Remove the enum and
port over the code in alsa.lua.
2022-07-14 13:02:19 +00:00
George Kiagiadakis
9def3f96d2 link: add WP_LINK_FEATURE_ESTABLISHED to track when a link is PAUSED/ACTIVE
This allows to transparently wait until a link is PAUSED before
returning from the activation transition. This way we can also
catch negotiation/allocation errors while activating a link.

PAUSED is used instead of ACTIVE because ACTIVE depends on the
nodes being activated as well. There are cases where a link may not
activate the nodes (ex, a passive link) and the link may remain
PAUSED for a long time.

Related to: #294
2022-07-02 17:10:22 +03:00
George Kiagiadakis
efaaf3b43a lua: add Core.get_vm_type() method 2022-06-28 14:06:48 +03:00
George Kiagiadakis
261ccf9972 si-node: skip control ports from the list of ports to be linked
Related to: #294
2022-06-28 10:52:49 +03:00
George Kiagiadakis
ba30a4fcec si-audio-adapter: skip control ports from the list of ports to be linked
Related to: #294
2022-06-27 17:35:29 +03:00
Julian Bouzas
0996f5a5ca spa-json: add wp_spa_json_to_string() API
Since the string length returned by wp_spa_pod_get_data() does not always match
the size of the actual json object because it is stored in contiguous memory, we
cannot always rely on that API to get the json string data.

The new wp_spa_pod_to_string() always allocates a new string with the same
length as the json size, guaranteeing that the string returned always represents
the json object, regardless of whether it is nested or not. It is always
recommented to use wp_spa_pod_to_string() unless you know what you are doing.
2022-06-27 10:07:16 +00:00
Julian Bouzas
76d87813a1 m-default-nodes: reevaluate nodes when ports changed
Currently, if the default node appears without ports for a short period of time,
the default nodes module will never select it immediately because it does not
listen for port changes. We want to listen for port changes to reevaluate again
the nodes that did not have ports before. This allows switching to the default
node as soon as it has ports if it did not had ports before.
2022-06-27 08:52:36 +00:00
Julian Bouzas
04198820f1 device: add new wp_spa_device_managed_object_new_iterator API 2022-06-27 08:52:36 +00:00
Julian Bouzas
46e7c5c144 m-reserve-device: use WpDbus API 2022-06-02 12:34:16 -04:00
Julian Bouzas
69b559399d modules: move all portal-permissionstore code into one file 2022-06-02 12:34:16 -04:00
Julian Bouzas
2c53486e0d m-portal-permissionstore: use WpDbus API 2022-06-02 12:34:16 -04:00
Michael Olbrich
13b85bd4a2 m-lua-scripting: fix object refcounting
7908b8d7be2a2992c57cd549054eda7ce46e4b44 ("m-lua-scripting: allow
converting GValue holding NULL objects to Lua") accidentally added a second
refcount. As a result, the objects are never freeded.

Remove the second refcount to fix this.
2022-05-24 11:40:35 +02:00
Julian Bouzas
392cce2136 m-default-nodes: don't check if all device nodes are ready when finding default node
This check was originally added to avoid a small audio glitch when changing
default nodes while also changing the device profile (eg Gnome Sound Settings).
The check is removed because it causes issues when disabling alsa nodes. There
are plans to fix the audio glitch issue in the future with the planned
event-dispatcher architecture.

Fixes #279
2022-05-20 13:39:47 +00:00
Julian Bouzas
c2f31bb550 m-lua-scripting: allow converting GValue holding NULL objects to Lua 2022-05-19 07:43:12 -04:00
George Kiagiadakis
2eed279c9d i18n: remove the module and embed the gettext calls into the lua api
There is no need to have this as an optional module, since libintl
is a hard dependency of both PipeWire and GLib. This way we can keep
things a bit simpler and faster (no string copies and plugin lookups)

Bump meson dependency to 0.59 to benefit of the libintl lookup that
is now built into meson's dependency() function.
2022-05-10 15:16:09 +03:00
Julian Bouzas
07179452e2 m-lua-scripting: add WpSiAdapter APIs 2022-05-05 08:09:21 +00:00
Julian Bouzas
1675b37617 si-adapter: add ports state change signal 2022-05-05 08:09:21 +00:00
Krisztian Kovacs
8af6f3df1c modules/logind: be more specific when creating the login monitor
We're only interested in notifications for user state changes, so we should
better be more specific about it when creating the systemd login monitor.

This avoids issues with sd_login_monitor_new() returning EINVAL if
systemd-machined is not running (and thus /run/systemd/machines does
not exist).
2022-05-02 08:27:43 +00:00
George Kiagiadakis
7b8e3e8088 m-mixer-api: fix channelVolumes array iteration in set-volume
Fixes: #250
2022-05-02 11:02:40 +03:00
George Kiagiadakis
81af8c2069 lua: sandbox: remove all traces of the minimal_std flag, as it's no longer used 2022-04-23 20:14:59 +03:00
George Kiagiadakis
ecb6100b77 m-lua-scripting: wrap every script in a WpPlugin and expose async activation api
This allows scripts to declare when they have finished their loading,
so we can now also know when wireplumber is done loading and ready to
handle clients

Related to !313
2022-04-23 20:14:59 +03:00
George Kiagiadakis
031bc65c20 lua: sandbox: relax the sandbox to allow more functionality in scripts
This enables the debug and coroutine libraries and some more functions
that are not really so risky to have around

Related to #121
2022-04-23 20:14:59 +03:00
George Kiagiadakis
9387ce0d95 wplua: implement reference counting of the lua_State 2022-04-23 20:14:59 +03:00
George Kiagiadakis
9c22f6076a wplua: enable the use of require() to load lua libraries from scripts/lib 2022-04-23 20:14:59 +03:00
George Kiagiadakis
e1d0240bc9 wplua: split the functionality of the load functions into smaller functions
The load functions used to do 3 things:
- push the sandbox function on the stack
- load the file and push it as a function on the stack
- call the sandbox (or the file)

Now there are separate functions to do these 3:
- wplua_push_sandbox
- wplua_load_*
- wplua_pcall
2022-04-23 20:14:59 +03:00
Pauli Virtanen
bbe9ac00f3 modules: add m-i18n
Add simple gettext i18n module.

Add Lua script API functions I18n.gettext, I18n.ngettext.
2022-04-11 19:20:43 +03:00
George Kiagiadakis
17a257ddbe wplua: move under modules/module-lua-scripting
It's unlikely that wplua will ever be useful outside the context
of module-lua-scripting, so let's move it to keep all the code in one place
2022-03-24 09:47:59 +02:00