34 Commits

Author SHA1 Message Date
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
Julian Bouzas
04198820f1 device: add new wp_spa_device_managed_object_new_iterator API 2022-06-27 08:52:36 +00:00
Julian Bouzas
844100360c proxy: abort activation if error or destroyed
This fixes a race condition that can happen when a proxy requests a new feature
(for example WP_NODE_FEATURE_PORTS) and PipeWire destroys the proxy before the
activation finishes. This race condition was causing the current activation
transition of a proxy to never finish, creating a memory leak because the
transition holds a strong reference of the proxy. Appart from this, since the
activation never finishes, WirePlumber could wait forever and not respond to
other requests.

This also removes the wp_proxy_watch_bind_error() API for subclasses as it is
not needed anymore.
2021-12-13 08:37:07 -05:00
Peter Hutterer
1121618387 lib: fix some incorrect docs for signals 2021-11-18 12:09:57 +00:00
Niklāvs Koļesņikovs
05334c1ec7 lib/wp/device: demote missing SPA warning to message
Warnings can be scary, so best not to scare users with what's likely
intentional omission of a particular SPA plugin (currently V4L & BlueZ).
2021-09-15 13:54:07 +03:00
Julian Bouzas
3fbcf05c9b pipewire-object: take ownership of param argument
The wp_pipewire_object_set_param API must take ownership of the param argument
as described by the documentation.
2021-06-03 14:53:00 -04: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
Julian Bouzas
8fdd99d956 global-proxy: delay object creation until bound feature is requested
Allows handling errors if creation fails
2021-05-18 09:24:33 -04:00
George Kiagiadakis
0b558eca74 proxy: add a "bind" watch, to watch for proxy errors while binding/exporting
Add a unit test for this. Create a link with invalid nodes and expect
the activation transition to error out.
2021-05-13 08:52:22 -04:00
Julian Bouzas
58db9e1fad global-proxy: destroy the global when proxy is destroyed 2021-05-12 14:04:34 -04:00
George Kiagiadakis
257d5cba47 wp: rename debug.{h,c} to log.{h,c}
Also rename the intermediate lua api table WpDebug -> WpLog

Keeps things more consistent with the function names (wp_log*),
with the lua api (Log.*) and with pipewire using log.{h,c} as well.
After all, these functions are for logging...
2021-05-06 15:50:07 +03:00
George Kiagiadakis
9b74fbc6ac device: debug and enhance spa device event handling 2021-04-16 20:01:56 +03:00
George Kiagiadakis
faff5c644c spa-device: do not assert if the activation transition fails 2021-03-16 16:15:32 +02:00
George Kiagiadakis
4a15ad05f3 spa-device: add an "object-removed" signal
This is useful for monitors to destroy the associated device reservation
object. And it may be useful for other things in the future...
2021-01-26 16:42:29 +02:00
George Kiagiadakis
674e53c221 spa-device: handle DeviceEvent and configure node props
Depends on DeviceEvent type-info, available on pipewire master as of today
2021-01-21 09:42:07 +02:00
George Kiagiadakis
18229e8265 spa-device: derive from WpProxy and manage child objects internally
port module-monitor to follow the changes
2021-01-21 09:42:07 +02:00
George Kiagiadakis
bd65517b7d pw-object-mixin: refactor, implement param caching and features for impl objects
Now the WpPipewireObject interface is directly implemented by the mixin
and there is another interface that users of the mixin must implement
in order for the mixin to work proprely.

A lot of manual stuff that proxy classes had to do before are now
in the mixin. Also most of the data that would normally reside in Private
structures is now in the mixin data structure (stored as qdata on the object).
This is achieving the best amount of code reuse so far.

For impl objects (WpImpl*) there are also default implementations of the
standard pipewire object methods and the INFO & PARAM_* features are
more coherently enabled during the whole lifetime of these objects.
2020-11-25 22:44:29 +02:00
George Kiagiadakis
2f3f5f8e66 lib: refactor WpProxy
This is an attempt to unclutter the API of WpProxy and
split functionality into smaller pieces, making it easier
to work with.

In this new class layout, we have the following classes:

- WpObject: base class for everything; handles activating
|           and deactivating "features"
|- WpProxy: base class for anything that wraps a pw_proxy;
 |          handles events from pw_proxy and nothing more
 |- WpGlobalProxy: handles integration with the registry

All the other classes derive from WpGlobalProxy. The reason
for separating WpGlobalProxy from WpProxy, though, is that
classes such as WpImplNode / WpSpaDevice can also derive from
WpProxy now, without interfacing with the registry.

All objects that come with an "info" structure and have properties
and/or params also implement the WpPipewireObject interface. This
provides the API to query properties and get/set params. Essentially,
this is implemented by all classes except WpMetadata (pw_metadata
does not have info)

This interface is implemented on each object separately, using
a private "mixin", which is a set of vfunc implementations and helper
functions (and macros) to facilitate the implementation of this interface.

A notable difference to the old WpProxy is that now features can be
deactivated, so it is possible to enable something and later disable
it again.

This commit disables modules, tests, tools, etc, to avoid growing the
patch more, while ensuring that the project compiles.
2020-11-13 19:54:48 +02:00
Julian Bouzas
ffd43f397b device: set parent type to GObject in WpSpaDevice structure 2020-10-15 12:04:05 -04:00
George Kiagiadakis
a3870581fb spa-device / m-monitor: fix pw_proxy leaks reported by pw_core
1. device export proxies must be destroyed manually since they are
   not associated with the WpRegistry
2. the monitors should not disconnect before all WpSpaDevice objects
   are destroyed; remove the manual disconnect call and let GObject
   ref counting do its job (the core will disconnect when its last ref
   count is dropped after the last monitor plugin is destroyed)
2020-06-29 13:05:44 +03:00
George Kiagiadakis
b70cbca84e spa-device: store the constructor properties and use them for export + object-info
the spa object undereath doesn't do that and we lose a bunch of
properties otherwise
2020-06-15 11:10:39 +03:00
Julian Bouzas
382b550d26 spa-device: don't destroy the task until the proxy is bound when exporting 2020-06-12 15:04:36 -04:00
George Kiagiadakis
8a0abd4fb8 spa-device: subclass from GObject 2020-06-11 15:05:20 +03:00
Julian Bouzas
9728418b6d spa-pod: remove const-ness from API 2020-06-04 09:48:43 -04:00
George Kiagiadakis
b17dab8c9b spa-device: delay activation until after the device is exported
this allows the created nodes to be able to set their "device.id"
property correctly
2020-06-02 17:24:14 +03:00
George Kiagiadakis
8a94937b2a proxy: refactor how PARAM_Props/PropInfo are handled
+ rename FEATURE_CONTROLS to FEATURE_PROPS
+ add accessor for the standard spa_param_info (info->params)
+ hide the low-level params API that nobody uses
2020-05-25 18:54:41 +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
d4973363ac lib: add extensive API documentation 2020-02-19 10:43:07 +02:00
George Kiagiadakis
9330208ada proxy/core: refactor object creation
* core no longer exposes create_remote/local_object
* node, device & link have constructor methods
  to enable the create_remote_object functionality
* added WpImplNode to wrap pw_impl_node and allow creating
  "local" node instances
* added WpSpaDevice to wrap spa_device and allow creating
  "local" device instances
* exporting objects in all cases now happens by requesting
  FEATURE_BOUND from the proxy, eliminating the need for WpExported
* replaced WpMonitor by new, simpler code directly in module-monitor
* the proxy type lookup table in WpProxy is gone, we now
  use a field on the class structure of every WpProxy subclass
  and iterate through all the class structures instead; this is
  more flexible and extensible
2020-02-11 11:07:44 +02:00
George Kiagiadakis
c671b0faca lib: drop the proxy- prefix from client, device, link, port & node 2020-01-22 19:46:17 +02:00