50 Commits

Author SHA1 Message Date
George Kiagiadakis
1e714fe784 session-item: improve class description 2023-09-26 09:57:50 +03:00
George Kiagiadakis
9970450bfa object.h: don't include core.h 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
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
9004362cda lib: remove WpEndpoint and WpSiEndpoint APIs 2023-04-17 07:48:18 -04:00
Julian Bouzas
63fbcdc82c session-item: remove ID property
Not needed anymore, the object API has a unique ID now.
2023-04-17 07:47:09 -04:00
Julian Bouzas
0c51cf9a7b session-item: fix reference leak when getting properties 2021-07-02 11:59:42 -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
a37b4bf20d session-item: add _get_property API 2021-05-12 10:36:31 -04:00
George Kiagiadakis
a93dbf0845 wp: remove WpSessionBin
This is no longer used and likely not very useful now that we have
a simpler design.
We can re-add it in the future if necessary, but let's keep it out
of the 0.4 release.
2021-05-06 16:04:39 +03: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
Julian Bouzas
ec30336fcf session-item: add id property
Makes it easier when handling session items in Lua
2021-03-26 16:16:02 -04:00
Julian Bouzas
3aef916d51 session-item: add _register and _remove API
Allows using object managers to listen for registered items
2021-03-18 14:30:11 -04:00
Julian Bouzas
120aab04ae session-item: refactor and inherit from WpObject
This adds WP_SESSION_ITEM_FEATURE_ACTIVE and WP_SESSION_ITEM_FEATURE_EXPORTED
features, so _activate and _export APIs have been removed. Modules and unit
tests have also been updated.
2021-03-18 14:30:05 -04:00
Julian Bouzas
12b2c00d0b lib: remove WpEndpointStream API
Add all that goes with it.
2021-03-18 12:10:37 -04:00
George Kiagiadakis
7eed2acd76 lib: documentation fixes 2021-03-04 19:10:10 +02:00
Julian Bouzas
7c0739af50 session-item: add export API with closure 2021-01-22 09:55:52 -05:00
Julian Bouzas
73c6e65a74 session-item: add activate API with closure 2021-01-22 09:55:52 -05:00
George Kiagiadakis
c2221915c9 session-item: move wp_session_item_set_parent() to the public header 2020-11-16 10:34:58 +02:00
George Kiagiadakis
91472c51e9 lib: move WpImplEndpoint* header parts to private/impl-endpoint.h 2020-11-15 20:26:15 +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
e1b85e1fe4 session-item: check for core before adding closure if proxy is destroyed 2020-05-15 08:21:49 -04:00
George Kiagiadakis
fe1ac40919 endpoint: ensure that streams are available when FEATURE_STREAMS is declared as ready 2020-05-11 09:56:06 +03:00
George Kiagiadakis
55f56fec2a session-item: remove the ACTIVATING/EXPORTING flag before the callback
It is a valid use case to do things like call wp_session_item_export()
from within the async ready callback of _activate(), and it's not
possible unless the ACTIVATING flag has been cleared first.

To do this, use a GCClosure to wrap the callback and install marshal
guards, which are called before and after the callback, to modify
the flags.
2020-05-08 19:56:08 +03:00
George Kiagiadakis
9db4a54591 session-item: handle destroyed endpoint links
We can now call wp_proxy_request_destroy() on endpoint links and
the WpImplEndpointLink together with the session item that created
it will be cleaned up
2020-05-07 16:02:23 +03:00
George Kiagiadakis
7966a8d456 si-standard-link: fix endpoint linking bugs and add some debug statements 2020-05-05 18:04:05 +03:00
Julian Bouzas
791e9170aa si-interfaces: transfer full when returning from _get_stream_parent_endpoint 2020-05-03 19:54:31 +03:00
Julian Bouzas
230c103f18 session-item: add _get_parent API 2020-05-03 19:54:31 +03:00
George Kiagiadakis
49b63b6045 session-item: refactor export to use a process similar to activate
+ expose the export transition in the session item class
+ make the export-related flags immutable
+ add an export error flag
+ update and improve documentation
2020-04-16 17:38:31 +03:00
George Kiagiadakis
441a778b2e session-item: introduce a rollback() virtual method
+ replace calling execute_step(..., STEP_ERROR) with rollback
+ implement deactivate internally using rollback

This unifies deactivation steps, which are common between deactivate()
and calling execute_step() with WP_TRANSITION_STEP_ERROR at the
end of a failed activation transition.
2020-04-16 13:18:21 +03:00
George Kiagiadakis
6b51e5842c tests: add session-item unit test 2020-04-16 11:55:23 +03: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
5d74bceac0 endpoint: implement create_link() 2020-04-11 11:05:26 +03:00
George Kiagiadakis
f713cbee11 session-item: decouple reset from deactivate and export from activate
* It should be possible to activate/deactivate while an item
  is exported (if the item supports it, but that's a subclass matter)
* It should be possible to deactivate without resetting configuration
2020-04-09 19:24:42 +03:00
George Kiagiadakis
27d1fd1ddd session-item: enable all standard endpoint features 2020-04-01 15:37:43 +03:00
George Kiagiadakis
a0521deaa5 session-item: implement exporting endpoint links 2020-03-31 19:40:49 +03:00
George Kiagiadakis
a1f47d0627 session-item: add _get_associated_proxy_id method
To ease the use case where we are only interested in the id
and not the proxy object itself
2020-03-31 19:26:05 +03:00
George Kiagiadakis
306f75d321 session-item: implement and use _get_associated_proxy() API 2020-03-31 16:11:08 +03:00
George Kiagiadakis
c8f83c99dc session-item: export streams 2020-03-31 16:11:08 +03:00
George Kiagiadakis
79a39e98c9 transition: call execute_step() with _STEP_ERROR in error conditions
This allows the implementation to rollback changes, cancel jobs, etc
2020-03-31 16:11:08 +03:00
George Kiagiadakis
b7566793b7 session-item: make WpSiTransition more generic to reuse it in _default_export() 2020-03-31 16:11:08 +03:00
George Kiagiadakis
405e8ba0d5 session-item / endpoint: implement exporting a WpSiEndpoint
* introduces API to export session items
* introduces small changes in the WpSiEndpoint & WpSiStream
  interfaces to make it nicer to work with
* ports WpImplEndpoint to use PW_TYPE_INTERFACE_Endpoint
  to export. Depends on:
  https://gitlab.freedesktop.org/pipewire/pipewire/-/merge_requests/246
  (was merged after 0.3.2)
2020-03-29 15:18:20 +03:00
George Kiagiadakis
763156e9f8 session-item: add an _activate_finish() method 2020-03-29 15:02:59 +03:00
George Kiagiadakis
dec8699728 session-item: implement default activation sequence with no steps
This allows activating a dummy item for unit testing
2020-03-29 15:02:59 +03:00
George Kiagiadakis
37d3c56d42 session-item: remove get_config_spec, in favor of using WpSiFactory 2020-03-29 15:02:59 +03:00
George Kiagiadakis
fc4fa4ca8a lib: implement WpSiFactory, a factory for session items 2020-03-29 15:02:59 +03:00
George Kiagiadakis
51f7897aa1 modules: implement the "adapter" session item, as a reference 2020-03-29 15:02:59 +03:00
George Kiagiadakis
32dd485649 lib: implement WpSessionItem base class 2020-03-29 15:02:59 +03:00