Commit Graph

35 Commits

Author SHA1 Message Date
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
George Kiagiadakis
f1bb4e3588 lib: implement proxy & proxy-registry 2019-04-15 17:07:06 +03:00
George Kiagiadakis
6f6e2b0e3e lib: implement plugin mechanism and a basic proxy object 2019-04-12 12:37:36 +03:00