Commit graph

687 commits

Author SHA1 Message Date
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
Duncan Overbruck
542e56d9f7
conf: fix equal matches 2023-06-17 20:07:58 +02:00
Julian Bouzas
19213efa9f event-hook: fix different signedness comparison warning 2023-06-05 15:20:44 -04:00
George Kiagiadakis
b347415501 main: move the code that loads the components section into the library
This allows it to be reused in other wireplumber clients and tests
2023-05-29 15:48:39 +03: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
d0e96358ea component-loader: add a load_finish() vfunc to finish the async operation
It's not acceptable to assume that the underlying implementation uses a GTask,
so we have to defer the finish function to the implementation as well
2023-05-26 19:21:51 +03:00
George Kiagiadakis
41c9de30bf core: move wp_core_load_component* declarations to component-loader.h 2023-05-26 18:59:42 +03:00
George Kiagiadakis
f53185e951 component-loader: move module loading to a new WpInternalCompLoader object 2023-05-26 13:49:40 +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
eb180cebe8 component-loader: convert WpComponentLoader to a GInterface 2023-05-25 19:20:40 +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
d755ec4f20 log: ensure that warnings from pw/spa are printed as warnings
converting a spa log level to a native log level is not trivial, it seems;
when we want to print a message, we should map 2 (WARN) to W, but when we
want to translate WIREPLUMBER_DEBUG=2 to a log level, we should map 2 to N
2023-05-25 18:25:41 +03:00
George Kiagiadakis
8912dc25c3 log: fix log level mask to be able to test the trace level
Trace is 1<<8 and the mask was 0xFF, allowing only bits 0-7
to be tested
2023-05-25 17:59:56 +03:00
George Kiagiadakis
ae7bed5655 log: make the level name a plain character in the log_level_info struct 2023-05-19 11:04:56 +03:00
George Kiagiadakis
cbf0d7284a log: make debug level 0 enable fatal errors
We always want to show fatal errors
2023-05-19 10:58:31 +03:00
George Kiagiadakis
3034fc7c79 log: accept 0 as a level and do safety checks on the level string 2023-05-19 10:50:46 +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
89c31d8190 log: disable "conn.*" topic by default, like pipewire does
This topic contains traces to debug the pipewire socket protocol.
Adding this pattern allows WIREPLUMBER_DEBUG=5 to show everything
except this trace by default, which is a more reasonable amount
of trace. To enable it, it must be explicitly specified in the
WIREPLUMBER_DEBUG env variable.
2023-05-18 15:53:50 +03:00
George Kiagiadakis
17b893c266 log: always set PIPEWIRE_DEBUG 2023-05-18 13:10:13 +03:00
George Kiagiadakis
b7e4654da4 log: rename log_level_index to level_index_from_flags, for consistency 2023-05-18 13:04:33 +03:00
George Kiagiadakis
dc548a3259 log: improve the initialization process
* initialize all log-related features in a new wp_log_init() function
* remove the ability to change the log patterns later, as the log
  topics are not referenced by the log system and there is no way to
  re-initialize them with different levels (we can still implement this
  in the future, if necessary, though)
* introduce the notion of a "global log level", referenced by all topics,
  and make the topics know if they have a custom level or not, like in
  pipewire; this is necessary to be able to set the level in the config
  file, which is read later by pw_context / WpCore.
2023-05-18 12:50:52 +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
George Kiagiadakis
e908b93f3b log: describe the syslog priority numbers for code clarity 2023-05-16 16:46:43 +03:00
George Kiagiadakis
2e2ccd5934 component-loader: update documentation 2023-04-25 16:06:32 +03:00
George Kiagiadakis
67f1eb585f log: implement different debug level per topic, like in pipewire 2023-04-25 08:50:13 +03:00
George Kiagiadakis
0fa484ac55 log: map spa ERROR and WARN to GLib's CRITICAL and WARNING respectively
Previously we were mapping SPA ERROR to GLib WARNING and
SPA WARN to GLib MESSAGE, which has been causing some confusion.

After some careful consideration, it makes sense to change that and
leave the GLib MESSAGE level as something to be avoided. With that
change, WIREPLUMBER_DEBUG=M will still enable the MESSAGE level,
but WIREPLUMBER_DEBUG=2 will only enable the WARN level and it will
take WIREPLUMBER_DEBUG=3 to enable both the INFO and MESSAGE levels.
2023-04-25 08:50:13 +03:00
George Kiagiadakis
e55e8bb447 object-manager: set self->installed=TRUE before emiting the signal
This avoids recursing into the same signal, in rare cases where a
new object is registered from within the signal handler
2023-04-17 07:48:18 -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
Torge Matthies
ab6a3393e6 lib/wp: Fix lookup_dirs with WP_LOOKUP_DIR_ENV_DATA or WP_LOOKUP_DIR_ENV_TEST_SRCDIR
Fixes: aa2f7e9f308f ("lib/wp: add a new search folder to locate the Lua Test scripts")
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
Julian Bouzas
ad940b6efc component-loader: remove handling of 'pw_module' components 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
cb80cb750b conf: add support to override sections and nested objects/arrays 2023-04-17 07:48:18 -04:00
Julian Bouzas
8f66b16673 lib: add WpConf API 2023-04-17 07:48:18 -04:00
George Kiagiadakis
18377fbf82 transition: don't allow _return_error() to be called recursively 2023-04-17 07:48:18 -04:00
Ashok Sidipotu
fcfae4eeb3 lib/wp: add a new search folder to locate the Lua Test scripts 2023-04-17 07:48:18 -04:00
George Kiagiadakis
ffa85840ac event: move cancelling of events on pw-proxy-destroyed to m-std-event-source
It is really out of place to do this inside WpEvent, as it is not
a generic action. It should only happen for some events.
2023-04-17 07:48:18 -04:00
George Kiagiadakis
3a23fb451a event-dispatcher: refactor to use before/after dependencies on hooks
* Remove entirely the hook priority numbers and use before/after dependencies
* Split the WpEvent code out of WpEventDispatcher
* Add methods on WpEvent to interface with it from the WpEventDispatcher.
  As a bonus, we can now also implement tooling to inspect which hooks would
  in theory run for an event and write tests around that
* Removed some internal debugging facilities and log calls, will redo it later.
* Using spa_list now for the list of hooks, to reduce the number of allocations
  happening in the "hook collection" algorithm
* Switched some internal data to use g_new0 instead of g_slice_new0
* Added g_free to free WpEvent structures... surprisingly, we were leaking them
  before
2023-04-17 07:48:18 -04:00
George Kiagiadakis
5a435fae11 event-dispatcher: expose iterator to iterate over the registered hooks 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
6c3bd9e27d event: add datalist to store arbitrary data on the event 2023-04-17 07:48:18 -04:00
George Kiagiadakis
24db3fe24a event-hook: rewrite the hook priorities enum
Hooks need to have a priority relative to the event they are executed on,
so it does not make much sense to have all kinds of different priorities
based also on the event type and/or the module where they are defined.
Also, it wouldn't be acceptable to have such an enumeration on the public API.
2023-04-17 07:48:18 -04:00
Julian Bouzas
102792527a lib: remove deprecated APIs 2023-04-17 07:48:18 -04:00
Ashok Sidipotu
d9d3a49f5a settings: remove unnecessary log message 2023-04-17 07:48:18 -04:00
Ashok Sidipotu
6f039003ec component-loader: support dangling components
- Dangling components are those not present in the json config files but present
in the wireplumber lookup folders.
2023-04-17 07:48:18 -04:00
George Kiagiadakis
497f30453d lib: event-hook/dispatcher: constness and staticness fixes 2023-04-17 07:48:18 -04:00
Julian Bouzas
1da43c6031 settings: append matches if the rule name matches 2023-04-17 07:48:18 -04:00