Commit Graph

54 Commits

Author SHA1 Message Date
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
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
d264bc460c registry: fix issues with dangling WpGlobal objects causing assertion failures
The main problem observed is when a link that is owned by a WpLink
is removed from the server because one of the linked nodes is gone.
This would cause the APPEARS_ON_REGISTRY flag to go away but the
WpGlobal would still remain in the globals list...

To fix this, forcibly remove the global from the globals list when
it is removed from the registry, even if it is still owned by some
proxy. The proxy at that point is unable to function anyway, because
we make sure to destroy the pw_proxy by removing FEATURE_BOUND when
the global is removed from the registry.

Additionally, ref global->proxy before removing FEATURE_BOUND to
prevent crashing. If the proxy owns the global and the pw-proxy-destroyed
signal causes whoever owns the proxy to drop his reference, _deactivate()
will crash because no-one will be holding a ref to the proxy.
2021-04-05 16:03:55 +03:00
George Kiagiadakis
5f1f96a5da registry: fix odd assertion failures that occured from time to time
The assumption about the global id in wp_registry_prepare_new_global()
was not valid because this function may also be called from the proxy
bound event and this may be before the registry has signalled the
removal of an old global with the same id, for instance

We should instead check this at the point where we expose the global.
If the assertion doesn't hold at that point, we are going to leak an
old WpGlobal, so we must ensure it.
2021-04-01 12:48:57 +03:00
George Kiagiadakis
7eed2acd76 lib: documentation fixes 2021-03-04 19:10:10 +02:00
Julian Bouzas
dc2ad1f25d rename all foo_iterate APIs to foo_new_iterator
Avoids confusion with LUA iterate API
2021-02-05 11:33:23 -05:00
Julian Bouzas
b7b3ce212b object-interest: add _ref and _unref APIs 2021-01-21 07:46:59 -05:00
George Kiagiadakis
af01155093 Merge branch 'master' into next-lua 2020-12-21 18:56:52 +02:00
George Kiagiadakis
e48cb30828 Fix compiler warnings that appear with the warning flags enabled
Fixes #20
2020-12-20 22:16:37 +02:00
George Kiagiadakis
7f40a8152d iterator: add version field in the methods struct
Similar to how pipewire interfaces are versioned.
Keeps the struct extensible without breaking ABI.
2020-11-16 11:16:35 +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
956cc83bfa object-manager: recursively store requested features on children
Now we have a deeper hierarchy, so requesting the features on WP_TYPE_PROXY
wouldn't properly request the features on WP_TYPE_NODE
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
George Kiagiadakis
a7d657a196 object-manager: do not accept globals without a WpProxy subclass 2020-06-01 17:48:31 +03:00
George Kiagiadakis
a30761c2f4 registry: forcibly add 'object.id' on all global properties
so that we can filter proxies by id on object managers
2020-05-31 12:19:47 +03:00
George Kiagiadakis
564e8a0db3 object-manager: fix iterator fold object access 2020-05-31 12:18:29 +03:00
Julian Bouzas
24cfa053eb object-manager: release interest when destroying iterator 2020-05-19 10:18:51 -04:00
George Kiagiadakis
5eecc5b68a object-manager: remove deprecated API 2020-05-14 16:24:34 +03:00
George Kiagiadakis
1e4a79c80e registry: do not expose early removed globals to object managers 2020-05-14 10:27:03 +03:00
George Kiagiadakis
d89c4ecd94 object-manager: don't try to install if there is no core
This happens when the daemon fails to connect and the
not installed object managers try to get installed, but
the weak ref to the core is already gone
2020-05-13 19:52:25 +03:00
George Kiagiadakis
151480f3e4 object-manager: wait until globals appear before emitting "installed"
object managers that are registered a bit early (such as the one in
wireplumber-cli) have no use if they are declared as installed before
any globals appear. After the initial registry startup, there should
be at least 1 global, the core (id=0), so even if this client has
no access to any object, the object manager should be able to
finish its installation successfully
2020-05-13 19:29:08 +03:00
George Kiagiadakis
f6dacf7cf7 lib: remove WpFactory (no longer used) 2020-05-13 15:29:17 +03:00
Julian Bouzas
5ea7e6fc0b object-manager: emit the object-removed signal after the object is removed 2020-05-12 13:37:36 -04:00
George Kiagiadakis
ded2e34eb6 global: properly destroy impl proxies that were removed by the server
When a pw_global is removed on the server (by pw_registry_destroy() or other
means), it triggers the proxy removed & the registry global_remove callbacks,
but it does not necessarily destroy the pw_proxy.

For client proxies, we were previously destroying them by unrefing the WpProxy
in wp_global_rm_flags(), since the global was not "owned" by the WpProxy.

For impl proxies, we were not doing anything, as we expected that it would
only be removed from the registry if the local WpProxy was destroyed first.
This is not always the case, though, as the server or another client may
request to destroy this proxy with pw_registry_destroy()

Now we always destroy the pw_proxy as soon as it is removed from the registry,
no matter if it was a client or an impl proxy. If it was an impl proxy,
the WpProxy will continue to live and it's up to the code that created it
to handle the "pw-proxy-destroyed" signal and do something meaningful.
If it was a client proxy, the global will still unref the WpProxy right after
destroying the pw_proxy and there is no change in behavior.
2020-05-07 15:50:14 +03:00
George Kiagiadakis
bd0ede2c6a object-manager: add _is_installed() method to query installation status 2020-05-07 15:45:00 +03:00
George Kiagiadakis
735b44c238 object-manager/proxy: sprinkle some debug/trace statements 2020-05-03 19:44:42 +03:00
George Kiagiadakis
9e1b5de93f object-manager: port to WpObjectInterest and add more useful API based on it 2020-05-01 19:23:54 +03:00
George Kiagiadakis
9f1b46eed6 object-manager: implement the 'installed' signal and improve state management
The 'installed' signal can be used to know that there are no
known objects that are being prepared internally, so the object
manager is ready to use.

This also improves internal state management so that the 'objects-changed'
signal cannot be fired earlier than it should. Previously there
were corner cases with complex proxy features, as the object manager
relied on the fact that after a core 'sync' it is safe to assume
that all proxies are augmented... that's not always the case.
2020-04-24 20:36:53 +03:00
Julian Bouzas
135b1c2cbf object-manager: only get proxy properties when needed 2020-04-21 16:11:05 -04:00
George Kiagiadakis
1dccdcf415 object-manager: replace GPtrArray API with WpIterator
+ add the useful _find_proxy() method
2020-04-21 13:21:03 +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
bb78b6bbc7 doc: remove references to WpImplEndpoint that is now private 2020-03-31 16:11:08 +03:00
George Kiagiadakis
c06317ac3b object-manager: add _get_n_objects() method 2020-03-31 16:11:08 +03:00
George Kiagiadakis
25d8e5e375 object-manager: look into the proxy object when checking constraints on a global
This allows having constraints on the pw properties and the GObject
properties of the proxy, instead of just on the global properties.

This is only useful for constraints on impl proxies, since the globals
coming from the registry don't have a proxy object associated at the
time they are added in the object managers
2020-03-31 16:11:08 +03:00
George Kiagiadakis
1a45e6504f object-manager: fix crash when global is removed before it was added in the globals list 2020-03-31 16:11:08 +03:00
George Kiagiadakis
d4973363ac lib: add extensive API documentation 2020-02-19 10:43:07 +02:00
George Kiagiadakis
77bb816b52 registry: change _prepare_new_global() to return the global in a less awkward way
the global is stored internally and the returned ref is only useful
in the WpProxy code, not in the registry_global() event
2020-02-17 18:41:36 +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
0b55729e06 registry: set a free func in the globals list
it doesn't matter, because we don't use it, but for the sake of readability
2020-02-17 16:43:47 +02:00
George Kiagiadakis
949100c9c0 object-manager: reorder code in object-manager.c 2020-02-14 17:19:41 +02:00
George Kiagiadakis
472d63e1b0 registry: fix internal documentation 2020-02-14 17:19:35 +02:00
George Kiagiadakis
51272907fe registry: expose tmp globals in the order they appeared on the pw registry
some code is expecting things to happen in that order...
2020-02-14 17:19:26 +02:00
George Kiagiadakis
813351bcdf registry: safely destroy proxy when its initial augment is still in progress
... in case the global is removed from the registry before
the initial augment completes
2020-02-14 17:19:15 +02:00
George Kiagiadakis
269b9e1998 registry: use a temporary globals list
When a new global is created, it is not certain
if the registry global event or the proxy bound event will
be fired first. In order to make sure we associate all
proxies to their WpGlobals correctly, we now wait a core sync
before exposing globals to the object managers, so that in case
the implementation proxy receives the bound event after the
registry creates the WpGlobal, we can make sure to use this
proxy instead of constructing a new one through the object managers
2020-02-14 17:18:58 +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
George Kiagiadakis
a92e1a64ec global & object-manager: use GType instead of the pipewire type 2020-02-12 14:15:51 +02:00
George Kiagiadakis
d8ae151aba proxy: replace global-id with bound-id
+ use the pw_proxy API to find the bound id instead
of relying on WpGlobal

This has the advantage that it works also for exported
objects and for objects that have been created by calling
into a remote factory (such as the link-factory), so we can
now know the global id of all proxies, not only the ones
that have been created by the registry.
2020-02-10 18:58:41 +02:00
Julian Bouzas
a9ac1fdc06 update to the latest pipewire API 2020-01-13 15:07:08 -05:00