wireplumber/lib/wp/core.h

80 lines
1.7 KiB
C
Raw Normal View History

/* WirePlumber
*
* Copyright © 2019 Collabora Ltd.
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
*
2019-05-31 12:13:01 +03:00
* SPDX-License-Identifier: MIT
*/
#ifndef __WIREPLUMBER_CORE_H__
#define __WIREPLUMBER_CORE_H__
#include <glib-object.h>
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:44:23 +02:00
#include "object-manager.h"
#include "proxy.h"
G_BEGIN_DECLS
2020-01-09 12:39:45 -05:00
struct pw_context;
#define WP_TYPE_CORE (wp_core_get_type ())
WP_API
G_DECLARE_FINAL_TYPE (WpCore, wp_core, WP, CORE, GObject)
2020-01-09 12:39:45 -05:00
/* Basic */
WP_API
WpCore * wp_core_new (GMainContext *context, WpProperties * properties);
WP_API
GMainContext * wp_core_get_context (WpCore * self);
WP_API
2020-01-09 12:39:45 -05:00
struct pw_context * wp_core_get_pw_context (WpCore * self);
/* Connection */
WP_API
2020-01-09 12:39:45 -05:00
gboolean wp_core_connect (WpCore *self);
WP_API
2020-01-09 12:39:45 -05:00
void wp_core_disconnect (WpCore *self);
WP_API
2020-01-09 12:39:45 -05:00
gboolean wp_core_is_connected (WpCore * self);
/* Callback */
WP_API
guint wp_core_idle_add (WpCore * self, GSourceFunc function, gpointer data,
GDestroyNotify destroy);
WP_API
2019-12-06 08:43:40 -05:00
gboolean wp_core_sync (WpCore * self, GCancellable * cancellable,
2019-12-04 15:20:42 -05:00
GAsyncReadyCallback callback, gpointer user_data);
2020-01-09 12:39:45 -05:00
/* Object */
WP_API
2020-01-09 12:39:45 -05:00
WpProxy * wp_core_export_object (WpCore * self, const gchar * interface_type,
2020-01-09 09:20:50 -05:00
gpointer local_object, WpProperties * properties);
WP_API
WpProxy * wp_core_create_local_object (WpCore * self,
2020-01-09 12:39:45 -05:00
const gchar *factory_name, const gchar * interface_type,
guint32 interface_version, WpProperties * properties);
WP_API
WpProxy * wp_core_create_remote_object (WpCore * self,
2020-01-09 12:39:45 -05:00
const gchar * factory_name, const gchar * interface_type,
guint32 interface_version, WpProperties * properties);
2020-01-09 12:39:45 -05:00
/* Object Manager */
WP_API
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:44:23 +02:00
void wp_core_install_object_manager (WpCore * self, WpObjectManager * om);
G_END_DECLS
#endif