Commit Graph

52 Commits

Author SHA1 Message Date
George Kiagiadakis
c46a48d13f registry: hide again the WpCore struct, separate registry and core better 2020-02-17 18:31:03 +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
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
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
George Kiagiadakis
c671b0faca lib: drop the proxy- prefix from client, device, link, port & node 2020-01-22 19:46:17 +02:00
George Kiagiadakis
5c47f1df2c proxy: unify common info/params API in the WpProxy base class 2020-01-22 18:30:44 +02:00
George Kiagiadakis
6f2844ac13 proxy: remove interface-quark
This is not used anymore. It was useful when we were using it as
a detail in the global-added signal, but that is gone now.
2020-01-22 18:07:16 +02:00
George Kiagiadakis
f7a0e710a5 lib: remove wp_proxy_sync in favor of wp_core_sync
They are equivalent, there is no real benefit in having both
2020-01-22 18:07:16 +02:00
Julian Bouzas
a9ac1fdc06 update to the latest pipewire API 2020-01-13 15:07:08 -05:00
Julian Bouzas
116376a0a6 proxy: add local_object property to handle local objects 2020-01-10 10:16:07 -05:00
Julian Bouzas
55ff0a6339 proxy: add WpProxyDevice subclass 2020-01-08 09:54:31 -05:00
George Kiagiadakis
a71d433a5e lib: implement WpEndpoint (interface + Proxy + Exported + unit test)
heavily based on the WpSession implementation
2019-12-11 19:05:09 +02:00
George Kiagiadakis
a4d8e85a96 proxy: construct WpProxySession for session proxies 2019-12-04 18:49:47 +02:00
George Kiagiadakis
d4b7e98748 proxy: add type associations for the new session-manager extension types 2019-12-03 18:05:34 +02:00
George Kiagiadakis
23b66a8f43 proxy: debug in dispose() so that we can print the pw_proxy pointer
in finalize() the pw_proxy is already gone and we always print null
2019-11-16 17:24:18 +02:00
George Kiagiadakis
e7e5c66853 lib: introduce WpObjectManager
* rework how global objects are stored in the core
* rework how users get notified about global objects
  and proxies of remote global objects

The purpose of this change is to have a class that can manage
objects that are registered in the core or signalled through the
registry. This object can declare interest on certain types
of global objects and only keep & signal those objects that it is
interested in. Additionally, it can prepare proxy features and
asynchronously deliver an 'objects-changed' signal, which is
basically telling us that the list of objects has changed.

This is useful to simplify port proxies management in WpAudioStream.
Now the stream object can declare that it is interested in ports
that have "node.id" == X and the object manager will only maintain
a list of those. Additionally, it will emit the 'objects-changed'
signal when the list of ports is complete, so there is no reason to
do complex operations and core syncs in the WpAudioStream class
in order to figure out when the list of ports is ready.

As a side effect, this also reduces resource management. Now we
don't construct a WpProxy for every global that pipewire reports;
we only construct proxies when there is interest in them!

Another interesting side effect is that we can now register an
object manager at any point in time and get immediately notified
about remote globals that already exist. i.e. when you register
an object manager that is interested in nodes, it will be immediately
notified about all the existing nodes in the graph. This is useful
to avoid race conditions between connecting the signal and objects
beting created in pipewire
2019-11-13 15:49:39 +02:00
George Kiagiadakis
f252f4be5b proxy: allow multiple augment tasks to run in parallel
This lifts the limitation of having a single entity externally
that augments the proxy and allows us to implement better
management of the proxies with the upcoming WpObjectManager
2019-11-11 17:41:06 +02:00
George Kiagiadakis
d39307ee70 lib/wp: move internal functions and declarations to a private.h header 2019-11-07 20:44:55 +02:00
George Kiagiadakis
9ab1780594 core & proxy: add some more assertions and debug messages for troubleshooting 2019-10-02 21:20:19 +03:00
George Kiagiadakis
94b1390d0e proxy: destroy the pw_proxy in dispose()
Because the proxy_event_destroy() handler now takes a ref to the
WpProxy, which is an error to do in finalize()
2019-09-17 19:53:20 +03:00
George Kiagiadakis
340b52fbee proxy: fix crash that happens when a client exits very quickly after starting
This is very easy to reproduce when the pipewire-alsa integration
is installed and you do 'arecord -l'; the alsa plugin connects and
disconnects again before the proxy is ready.

In this case we have to skip remote-global-added and we also have
to be careful with the references: the global-removed callback is
called earlier, so the core's reference to the proxy is gone and
the GTask is the only thing holding a reference to the proxy.
When we unref the GTask, the proxy is also unrefed, so we have
to keep an additional reference in order to avoid crashing
when accessing the hash table below.
2019-09-17 16:19:13 +03:00
George Kiagiadakis
a63f2bb99b lib/wp: merge both WpRemote & WpRemotePipewire in WpCore
In practice we always create a remote and connect to pipewire.
Any other scenario is invalid, therefore, it is not justified
to be confused with so many classes for such small functionality.
This simplifies a lot the modules code.

Also, this commit exposes the pw_core and pw_remote objects
out of WpCore. This is in practice useful when dealing with low-level
pw and spa factories, which are used in the monitors. Let's not
add API wrappers for everything... Bindings will never use this
functionality anyway, since it depends on low level pipewire C API.
2019-09-07 17:55:46 +03:00
George Kiagiadakis
3d46253dd6 proxy: hide the bind() API and fix attaching the listener in wrap mode
In case the proxy was created with wp_proxy_new_wrap(), the event
listener was not attached on the pw_proxy
2019-08-29 21:21:51 +03:00
George Kiagiadakis
7608ae37b5 lib: implement WpProxyClient 2019-08-27 18:28:58 +03:00
George Kiagiadakis
e5a05dcc2b proxy-*: improve proxy subclasses
* add proxy sync method
* add wrapers for enum/set/subscribe_params
* move the info structure handling to the subclasses
* expose info->props as WpProperties
2019-08-27 17:40:28 +03:00
George Kiagiadakis
bdce3b4de5 proxy: refactor the proxy class to hide pipewire API and make things easier 2019-08-25 12:44:47 +03:00
George Kiagiadakis
baaccc92f7 proxy: fix the naming of variables that point to the instance and private structures 2019-07-25 12:27:40 +03:00
Julian Bouzas
dbd763bc9c proxy: throw an error if the proxy is destroyed during async constructions 2019-07-25 12:24:47 +03:00
Julian Bouzas
682bc6a6eb proxy: allow derived classes to finish its creation 2019-07-10 11:22:29 -04:00
Julian Bouzas
e73553088b proxy: remove unneeded destroy signal 2019-06-27 07:23:20 -04:00
Julian Bouzas
83394022cb proxy: don't remove the listener on destruction as it is not needed 2019-06-20 11:59:51 -04:00
Julian Bouzas
236ea5e0f2 proxy: add wp_proxy_sync API and DONE signal 2019-06-20 11:59:51 -04:00
George Kiagiadakis
1e6c7488bd proxy: avoid crashing when the WpProxy is unrefed in the "destroyed" signal handler 2019-06-20 18:55:50 +03:00
Julian Bouzas
fc7ebc2c31 proxy: add global_id property 2019-06-19 09:07:00 -04:00
Julian Bouzas
a471a2df13 proxy: remove unneeded core reference 2019-06-18 10:18:21 -04:00
Julian Bouzas
922065f97d proxy: add destroyed signal 2019-06-18 10:09:40 -04:00
George Kiagiadakis
e603ed4215 lib: add some debug statements to debug the destruction sequence 2019-06-18 10:33:38 +03:00
George Kiagiadakis
64affcaf49 proxy: maintain a weak ref to the core
avoids criticals and crashes when the core is destroyed earlier
2019-06-18 10:21:58 +03:00
Julian Bouzas
aa1ce5cdd4 proxy: add API 2019-06-17 10:42:29 -04:00
George Kiagiadakis
447c968846 Refactor everything!
After discussing things at the AGL May 2019 F2F meeting
and reflecting on the initial design of WirePlumber,
it became clear that it needed a fresh start.
2019-05-17 13:34:07 +03:00
George Kiagiadakis
43365715f7 many crash fixes 2019-04-28 14:20:00 +03:00
George Kiagiadakis
e16e66de2d lib: object/interface: do not (transfer full) interfaces and objects 2019-04-26 13:19:18 +03:00
George Kiagiadakis
02c69fd2fa proxy: add methods to get info & enum params 2019-04-26 12:36:49 +03:00
George Kiagiadakis
cb1b3ebfad proxy: expose pw properties as a spa_dict and store them in a pw_properties
Exposing a spa_dict is necessary to allow using native pipewire API
that deals with these properties.

The internal structure change avoids mem copies when we need to
return a spa_dict.

This commits also removes exposing internal info structures via the
properties mechanism. This needs more thinking...
2019-04-23 16:28:13 +03:00
George Kiagiadakis
4fcdb931be proxy/plugin: hold a pointer to the core instead of the respective registry
This makes it more intuitive to get other attached interfaces
from the core
2019-04-22 17:48:02 +03:00
George Kiagiadakis
55365e97c1 lib: proxy: make the pipewire property getter an interface on WpObject
We are going to use this in other object types as well
2019-04-22 12:44:42 +03:00
George Kiagiadakis
87d60a80aa proxy: subclass from WpObject to allow attaching interfaces dynamically 2019-04-17 16:12:03 +03:00