Commit Graph

63 Commits

Author SHA1 Message Date
George Kiagiadakis
7428d20c94 proxy: add a wp_proxy_get_property() method to get a single pw property 2020-05-20 18:08:35 +03: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
3b086167ae proxy: add _request_destroy() method for destroying remote objects
Useful to destroy links and endpoint-links
2020-05-07 15:47:15 +03:00
George Kiagiadakis
735b44c238 object-manager/proxy: sprinkle some debug/trace statements 2020-05-03 19:44:42 +03:00
George Kiagiadakis
83f399395c proxy: emit 'bound' after setting FEATURE_BOUND
signal handlers expect FEATURE_BOUND to be set
2020-05-03 17:46:49 +03:00
Julian Bouzas
0045fe03c9 proxy: add set and get control vmethods, and remove them from sub-classes 2020-04-21 16:11:05 -04: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
c078a97d77 proxy: add 'bound' signal 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
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