86 Commits

Author SHA1 Message Date
Pauli Virtanen
7f30adeb42 core: fix WpLoopSource lifecycle
Currently nothing removes the WpLoopSource from the main context, and we
moreover are creating and attaching unused WpLoopSources when sharing
same pw_context between multiple WpCore.

Fix this by keeping track of the WpLoopSource in the pw_context user
data, only creating them when needed, and finalizing it after the
context is destroyed.
2024-04-22 08:49:28 +00:00
Pauli Virtanen
7997fd490b core: keep pw loop entered exactly when it is running
It is intended that the Pipewire loops are "entered" the whole time they
are running, i.e. are going to process further events. Currently we
enter/leave for single iterations, which is not right.

Fix by entering the loop on initial GSource idle callback, and leaving
at finalize.

That the loop has to be left from the same thread it was entered from is
a bit hard to do with GSources, as the finalize callback appears not
guaranteed to be called from any particular thread.  I didn't find a
fully general way to do this, so this puts additional constraints on how
WpLoopSource (and WpCore) are to be cleaned up.
2024-04-22 08:49:28 +00:00
George Kiagiadakis
7856124df0 core: set context.modules.allow-empty to silence warning in pw_context
See cddea858d9

Closes: #620
2024-04-03 11:52:18 +03:00
George Kiagiadakis
9c3aa5409e core: close the configuration file after loading all components
All components are supposed to read the configuration file during
initialization. After that, the file is not needed anymore.
2024-03-04 16:33:14 +00:00
George Kiagiadakis
60382df63f conf: refactor configuration loading
Changes:

- Configuration files are no longer located by libpipewire,
  which allows us to control the paths that are being looked up.
  This is a requirement for installations where pipewire and
  wireplumber are built using different prefixes, in which case
  the configuration files of wireplumber end up being installed in
  a place that libpipewire doesn't look into...

- The location of conf files is now again $prefix/share/wireplumber,
  /etc/wireplumber and $XDG_CONFIG_HOME/wireplumber, instead of using
  the pipewire directories. Also, since the previous commits, we now
  also support $XDG_CONFIG_DIRS/wireplumber (typically /etc/xdg/wireplumber)
  and $XDG_DATA_DIRS/wireplumber for system-wide configuration.

- Since libpipewire doesn't expose the parser, we now also do the
  parsing of sections ourselves. This has the advantage that we can
  optimize it a bit for our use case.

- The WpConf API has changed to not be a singleton and it is a
  property of WpCore instead. The configuration is now expected
  to be opened before the core is created, which allows the caller
  to identify configuration errors in advance. By not being a singleton,
  we can also reuse the WpConf API to open other SPA-JSON files.

- WpConf also now has a lazy loading mechanism. The configuration
  files are mmap'ed and the various sections are located in advance,
  but not parsed until they are actually requested. Also, the sections
  are not copied in memory, unlike what happens in libpipewire. They
  are only copied when merging is needed.

- WpCore now disables loading of a configuration file in pw_context,
  if a WpConf is provided. This is to have complete control here.
  The 'context.spa-libs' and 'context.modules' sections are still
  loaded, but we load them in WpConf and pass them down to pw_context
  for parsing. If a WpConf is not provided, pw_context is left to load
  the default configuration file (client.conf normally).
2024-03-04 07:07:56 +00:00
Pauli Virtanen
d8a345a30c log: rename back to wp_log_set_level 2024-01-13 16:33:05 +00:00
Pauli Virtanen
4e17edb1ac wp: make wp_log_set_global_level public API
Applications may want to change WP log level at runtime.

Also change it to return error stataus instead of printing warnings on
error.
2023-12-24 17:58:30 +02:00
George Kiagiadakis
c2d125b0da Merge branch 'master' into next 2023-12-23 18:34:00 +02:00
George Kiagiadakis
a6bea40172 core: add wp_core_get_own_bound_id() method
This allows retrieving the bound-id of our own client
2023-11-10 11:27:13 +02:00
George Kiagiadakis
67f9f63520 Merge branch '0.4' into next 2023-09-01 19:12:20 +03:00
Tom A. Wagner
6e81dc7a66 docs: Add missing '\since' attributes to types and functions that have been added in versions later than 0.4.0 2023-08-30 11:20:06 +02: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
840a2304b4 core: load components internally and refactor main to just activate it
+ move the export-core creation and media-session check to be built-in components
+ add WpCore API to find the export core
2023-06-23 18:01:26 +03:00
George Kiagiadakis
11add27f81 core: refactor to subclass from WpObject 2023-06-23 18:01:26 +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
f53185e951 component-loader: move module loading to a new WpInternalCompLoader object 2023-05-26 13:49:40 +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
903fab9c3c core: return true from _is_connected() only after receiving the info structure 2023-04-17 07:48:18 -04:00
Julian Bouzas
cee5ee7c37 core: add API to get virtual machine type 2022-06-02 12:34:16 -04:00
Wim Taymans
88d9b30d7a lib: remove some listeners 2022-02-09 12:38:27 +01:00
George Kiagiadakis
57d60c383c core: add wp_core_sync_closure()
A variant of wp_core_sync() that can be used with a GClosure
2021-12-21 20:03:58 +02:00
Jason Francis
ed8346e77d docs: Add brief descriptions to all functions
This ensures all of these functions are picked up by g-ir-scanner.
2021-06-02 17:38:34 +00:00
George Kiagiadakis
b812e912d2 docs: fix C API documentation to work nicely with doxygen & sphinx 2021-05-25 14:19:53 +03:00
Raghavendra
d692f06f0d docs: api: Replace hotdoc specific commands with Doxygen specific commands 2021-05-25 14:19:53 +03:00
George Kiagiadakis
6939d8900a core: use log.level from the pw_context
And don't override PIPEWIRE_DEBUG, unless WIREPLUMBER_DEBUG is set.
This allows pipewire to use log.level as well to set up its logging.

If WIREPLUMBER_DEBUG is set, though, override PIPEWIRE_DEBUG to prevent
log.level from being used.
2021-04-21 19:03:47 +03:00
George Kiagiadakis
7eed2acd76 lib: documentation fixes 2021-03-04 19:10:10 +02:00
George Kiagiadakis
37134df7c8 iterator: make private stuff public, cleanup private.h further
There is no good reason to keep them private
2020-11-15 20:26:15 +02:00
George Kiagiadakis
083b9ff878 core: wp_core_get_context -> wp_core_get_g_main_context 2020-06-16 12:53:18 +03:00
George Kiagiadakis
7668f4c6c9 core: add methods to work with pw_core_info data and pw_core properties
- pw_core_info has data that represent the remote core
- pw_core properties are the properties of its pw_client,
initially inherited from the pw_context, which can be updated either
when calling pw_context_connect() or later at runtime (the pw_core
calls pw_client_update_properties() on its pw_client)

wp_core_update_properties() is made in such a way so that we can do:
```
clone = wp_core_clone(core);
wp_core_update_properties(clone, ...);
wp_core_connect(clone);
```
and get clone to have different properties than the original core,
while they still share the same pw_context underneath
2020-06-15 17:50:03 +03:00
George Kiagiadakis
0596988945 core: retrieve and store core info
also delay the "connected" signal until info is there
2020-06-15 17:49:21 +03:00
Julian Bouzas
c7982a8317 core: rename context property to g-main-context 2020-06-10 13:29:52 -04:00
Julian Bouzas
eb39dec68b core: add wp_core_clone API 2020-06-10 13:29:44 -04:00
Julian Bouzas
d9ffc1c318 core: finish all pending tasks when core proxy is destroyed 2020-05-19 10:18:51 -04:00
George Kiagiadakis
9b0417cb68 core: remove warning on the error callback
libpipewire already prints this, so we get it duplicated on the log
2020-05-13 19:56:55 +03:00
George Kiagiadakis
8e87bd323c core: fix disconnecting when pipewire quits 2020-05-13 15:20:26 +03:00
George Kiagiadakis
66a0bf6093 lib: implement a wp_init() function 2020-05-11 15:45:09 +03:00
George Kiagiadakis
63397a1ff2 core: debug core sync 2020-05-08 18:18:33 +03:00
George Kiagiadakis
11b99527b5 core: make the properties on wp_core_new to be (transfer full)
This aligns better with the general design of consuming property
objects on constructors, both in PipeWire and WirePlumber APIs
2020-05-08 17:12:31 +03:00
George Kiagiadakis
a10ee91bd4 core: add idle & timeout method variants that take a GClosure 2020-05-07 11:10:12 +03:00
George Kiagiadakis
1faa752cd0 core: trace pw main loop execution 2020-04-24 20:42:27 +03:00
Julian Bouzas
cfbcb5eca3 proxy: use WpSpaPod instead of struct spa_pod in public API 2020-04-21 16:11:05 -04:00
George Kiagiadakis
9ca342f89f debug: update all library code to use the new debug system
+ enable the new log writer on the executables
+ enable structured logging in the tests
2020-04-14 18:31:17 +03:00
George Kiagiadakis
1cc2837562 lib: add proxy & impl class for PW_TYPE_INTERFACE_EndpointStream 2020-03-31 16:11:08 +03:00
Julian Bouzas
620f95b628 core: add source nullable parameter in _idle_add and _timeout_add APIs 2020-02-27 08:39:10 -05:00
Julian Bouzas
5abdc2fb9e core: add wp_core_timeout_add API 2020-02-27 08:37:15 -05:00
George Kiagiadakis
d4973363ac lib: add extensive API documentation 2020-02-19 10:43:07 +02:00
George Kiagiadakis
c46a48d13f registry: hide again the WpCore struct, separate registry and core better 2020-02-17 18:31:03 +02:00
George Kiagiadakis
753e708544 object-manager: refactor to be able to track locally created proxies
There are 3 kinds of WpProxy objects:
 * the ones that are created as a result of binding a global
   from the registry
 * the ones that are created as a result of calling into a remote
   factory (wp_node_new_from_factory, etc...)
 * the ones that are a local implementation of an object
   (WpImplNode, etc...) and are exported

Previously the object manager was only able to track the first kind.
With these changes we can now also have globals associated with
WpProxies that were created earlier (and caused the creation of the global).
This saves some resources and reduces round-trips (in case client
code wants to change properties of an object that is locally
implemented, it shouldn't need to do a round-trip through the server)
2020-02-14 17:12:23 +02:00