Commit graph

395 commits

Author SHA1 Message Date
George Kiagiadakis
03098c88bb bt-pinephone.lua: remove useless variable assignments
This is a copy/paste from the code that now lives in apply-routes.lua,
but there is no point since the route here is a real route param and
not a route_info structure.
2024-01-08 12:28:21 +02:00
George Kiagiadakis
c2d125b0da Merge branch 'master' into next 2023-12-23 18:34:00 +02:00
George Kiagiadakis
4593245fbb comp-loader: add support for wireplumber.components.rules
This is a new rules section that allows defining rules to modify
component definitions. This is useful to add repetitive dependencies,
for example, as in the case of "type = script/lua" that always requires
the "support.lua-scripting" feature. This can also be useful to modify
other component properties, such as the arguments, in overriding
configuration files, without needing to redefine the whole components
section.
2023-11-14 12:42:32 +02:00
George Kiagiadakis
42b64bfc28 spa-json: rename _from_string() to _wrap_string() and add new "from" variants
The previous naming convention was confusing because it did not make
it explicit that the string is not being copied. We had this wrong already
in the Lua bindings and thanks to some miracle it hasn't backfired so far
(it was using the "wrap" behaviour with a string that doesn't stay alive).

In some places we actually need the "copy" behaviour and in some other
places we need the "wrap" behaviour, so let's have both variants available.
2023-11-14 12:36:10 +02:00
George Kiagiadakis
e88fa840f2 lua: json: add optional argument in the json parse() method to limit the number of recursions
This allows partially parsing a json object, allowing some parts to be
passed on as strings to another component that does its own parsing
(ex. a pipewire module)
2023-11-10 11:27:13 +02:00
George Kiagiadakis
18ea9606d2 tests: fix script-tester to work with the metadata.lua changes 2023-11-08 20:37:13 +02:00
George Kiagiadakis
a6dd60ff83 conf: remove wp_conf_apply_rules() 2023-11-07 16:36:49 +02:00
George Kiagiadakis
fbecc50319 lua: api: bind json-utils functions 2023-11-07 16:36:49 +02:00
George Kiagiadakis
89ac416e99 lib: add new json-utils set of functions
The purpose is to wrap some utilities that pipewire provides that use JSON.

Start by wrapping pw_conf_match_rules(), which despite its name, it has nothing
to do with the configuration object. It operates directly on JSON and can be
useful to work with match rules outside the context of configuration files.
2023-11-07 16:36:49 +02:00
Pauli Virtanen
0809a89442 tests: script-tester: fix locking of test-server
Calling functions on test server must lock the thread loop, otherwise
the concurrency causes corruptiont in module-protocol-native and you get
bogus messages etc.
2023-11-01 21:00:55 +02:00
George Kiagiadakis
1e40108d94 linking-utils: rename unwrap_find_target_event -> unwrap_select_target_event 2023-09-30 12:06:40 +03:00
Ashok Sidipotu
d4f3e2bdca tests: replace "policy" with "linking" 2023-09-26 10:09:47 +03:00
George Kiagiadakis
0d8dfc8187 tests: add test for glob patterns in hook dependencies 2023-09-24 00:23:34 +03:00
Julian Bouzas
56017fdbe6 scripts: use filter-utils to implement smart filter policy 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
Duncan Overbruck
15f5d84d47 tests: add event dispatch order test for same priority events 2023-09-03 17:30:03 +03:00
George Kiagiadakis
67f9f63520 Merge branch '0.4' into next 2023-09-01 19:12:20 +03:00
Julian Bouzas
227dd97036 m-lua-scripting: always parse JSON to String if its type is not recognized
This allows parsing JSON strings without quotes.
2023-08-11 14:48:13 -04:00
George Kiagiadakis
98cd13284c tests: wait for the cores to connect before starting
Otherwise we end up executing the test without
an established connection
2023-07-04 15:09:31 +03:00
George Kiagiadakis
f94519a67a tests: upgrade failure notices to criticals
It's not very clear that these are the cause of failure when you look
at the logs
2023-07-04 14:57:26 +03:00
George Kiagiadakis
84d3382292 config: make it possible to have feature profiles
A profile is a list of features set to required/optional/disabled
which governs which components are getting loaded, given a static
components list with well-defined dependencies
2023-06-23 20:15:26 +03:00
George Kiagiadakis
a982b7917c tests: reduce logs coming from libpipewire
These tests are meant to catch wireplumber issues, so the libpipewire
logs are not very interesting and just make it hard to go through
the interesting bits
2023-06-23 18:01:26 +03:00
George Kiagiadakis
a0497b4256 Merge branch '0.4' into next 2023-06-21 20:59:04 +03:00
George Kiagiadakis
19cfd37da6 comp-loader: register the component & feature only if it activates successfully
Fixes #470
See also !503
2023-06-20 17:20:01 +03:00
George Kiagiadakis
db5bd534ce tests: do not explicitly free f->base.conf_file
This is done inside wp_base_test_fixture_teardown() now, as it should.
2023-06-20 12:39:29 +03:00
George Kiagiadakis
e738076cb0 conf: refactor component loading to use a dependency system
Each component can now list required and optional dependencies,
using the component feature names to match other components.
In addition, each component feature can be declared as required, optional
or disabled, making optional components easier to deal with.
The component flags (ifexists, nofail) have been removed.

Using virtual components, this system also allows easier customization
of which components should be loaded for a specific configuration,
without requiring the user to copy the list of components and edit it.

Also bump the required glib version to 2.68 for g_assert_cmpstrv()
2023-06-20 12:39:29 +03:00
George Kiagiadakis
9c2d25b985 tests: add component loader unit test 2023-06-20 12:39:29 +03:00
George Kiagiadakis
8a8cd97ca8 core: make the object registration functions public
This allows registering arbitrary objects on the core's registry and
finding them later, without having to add API for each and every object.

I think this is useful enough to have it public, even though it's
probably not going to be used that much... The rationale here is to
allow registering custom component loaders without having to make them
subclass WpPlugin or to create custom API for registering component
loaders specifically.

Also, remove the wp_plugin_register() and wp_si_factory_register()
functions, since they are not going to be used much in the future.
The idea is to let the component loader do the registration under the
scenes, as the component is getting loaded.
2023-06-20 12:39:29 +03:00
George Kiagiadakis
c7cb193588 core: introduce the notion of provided features on components
Each component can optionally "provide" a feature, which is basically
a string that describes the feature (ex. "support.dbus"). If the
component loads successfully, the feature is marked as provided and
can be tested for its presence with wp_core_test_feature()
2023-06-20 12:39:29 +03:00
George Kiagiadakis
add310d9eb dbus: refactor WpDBus into a plugin called dbus-connection
Now that we have proper module load order, we can have this shared
dbus connection in a module instead of the library. The module has
to be loaded before any other modules that need it, obviously.
2023-06-20 12:39:29 +03:00
Julian Bouzas
e24e52c6d3 spa-json: encode the string directly into the builder
Some special characters like '\v' are encoded using 6 characters, which
currently does not work because the VLA size asumes a maximum of 4 characters
per encoded special character. This patch refactors this logic to avoid using
VLAs at all and encodes the string directly into the builder.

See #471
2023-06-19 12:03:23 -04:00
Julian Bouzas
e91a9583d8 spa-json: Fix conditional jump on uninitialised value when adding empty strings to builder
Similar to wp_spa_json_builder_add_property(), we need to make sure the dst
array in wp_spa_json_builder_add_string() has room for the null character
because builder_add() expects it.

Fixes #471
2023-06-19 08:07:02 -04:00
Duncan Overbruck
575030aaf3
tests: add conf test for equal matches 2023-06-17 20:07:11 +02:00
George Kiagiadakis
55fc845098 component-loader: make wp_core_load_component_finish() return a boolean
There is no reason to return the component object... all components
are supposed to be long-lived objects that are referenced by the
registry and there is API to find them. The caller is only interested
in the success or failure of the operation.
2023-05-28 21:07:15 +03:00
George Kiagiadakis
7fdbf7ff50 component-loader: activate & register objects through a common code path
Do this in wp_core_load_component() and let the component loaders worry
only about creating the object.

Also run the main loop in tests while loading components, to ensure
that the async operation finishes before continuing execution. GTask
makes sure to make the operation async always, by emitting the callback
from an idle GSource.
2023-05-26 21:22:48 +03:00
George Kiagiadakis
843e7ef4dd component-loader: pass core and cancellable parameters in load()
Regarding the core parameter, the case used to be that WpComponentLoader
was a WpPlugin, so it had a reference to the core internally, but since
this is no longer a requirement, we need to pass this explicitly
2023-05-26 13:04:10 +03:00
George Kiagiadakis
5c3032c064 core: change the component arguments to be WpSpaJson instead of GVariant
This allows us to pass entire JSON objects from the config file
down to the modules / scripts without any conversion
2023-05-25 18:29:58 +03:00
George Kiagiadakis
bd672b71f7 script-tester: decouple script tests setup/teardown from basic
basic_tests_setup points to a config file that doesn't exist in
the script tests directory
2023-05-24 19:45:58 +03:00
George Kiagiadakis
49ea4d90f6 tests: run with WIREPLUMBER_DEBUG=T, not 7... 2023-05-19 21:13:19 +03:00
George Kiagiadakis
4f27d18bd3 log: rename "message" level to "notice" and print criticals with "E"
Syslog calls this level "notice" and I prefer it because we use it
to display significant messages that are not warnings, but they
are not really "standard", as GLib wants them to be. There is nothing
"standard" about log messages in general.

Also, make these notice messages be enabled at debug level 2, together
with warnings. The default log.level is 2 and it is a good idea to show
notices by default too.

Finally, show them in the log with "N" and also change criticals to be
shown with "E", meaning "error"... Then promote G_LOG_LEVEL_ERROR
messages to be shown with "F", meaning "fatal", because in fact these
messages are always fatal and always call abort(). Still, keep the term
"critical" in the functions to make sure that whoever uses them is aware
that this level is only for critical conditions and not suitable to
display any kind of error.
2023-05-18 16:19:49 +03:00
George Kiagiadakis
4736d56557 log: implement a log topics system, like pipewire
The intention is to make checks for enabled log topics faster.

Every topic has its own structure that is statically defined in the file
where the logs are printed from. The structure is initialized transparently
when it is first used and it contains all the log level flags for the levels
that this topic should print messages. It is then checked on the wp_log()
macro before printing the message.

Topics from SPA/PipeWire are also handled natively, so messages are printed
directly without checking if the topic is enabled, since the PipeWire and SPA
macros do the checking themselves.

Messages coming from GLib are checked inside the handler.

An internal WpLogFields object is used to manage the state of each log
message, populating all the fields appropriately from the place they
are coming from (wp_log, spa_log, glib log), formatting the message and
then printing it. For printing to the journald, we still use the glib
message handler, converting all the needed fields to GLogField on demand.
That message handler does not do any checks for the topic or the level, so
we can just call it to send the message.
2023-05-16 20:42:28 +03:00
matoro
b7d41ac5bd tests: common: crank up timeout for slower devices
Timeout of 3 seconds is too slow for test-si-standard-link on slower
devices, crank this up with plenty of extra margin.  Does not
practically affect running time on faster devices.
2023-04-20 17:53:35 -04:00
George Kiagiadakis
903fab9c3c core: return true from _is_connected() only after receiving the info structure 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
e7c992e97d default-nodes-tests: use the changed variable in test utils 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
9a0f8647ac test-utils: align style 2023-04-17 07:48:18 -04:00