
* 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
94 lines
2.2 KiB
C
94 lines
2.2 KiB
C
/* WirePlumber
|
|
*
|
|
* Copyright © 2019 Collabora Ltd.
|
|
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
|
|
*
|
|
* SPDX-License-Identifier: MIT
|
|
*/
|
|
|
|
#ifndef __WIREPLUMBER_PRIVATE_H__
|
|
#define __WIREPLUMBER_PRIVATE_H__
|
|
|
|
#include "core.h"
|
|
#include "object-manager.h"
|
|
#include "proxy.h"
|
|
|
|
G_BEGIN_DECLS
|
|
|
|
/* core */
|
|
|
|
struct pw_core_proxy;
|
|
struct pw_registry_proxy;
|
|
|
|
struct pw_core_proxy * wp_core_get_pw_core_proxy (WpCore * self);
|
|
struct pw_registry_proxy * wp_core_get_pw_registry_proxy (WpCore * self);
|
|
|
|
gpointer wp_core_find_object (WpCore * self, GEqualFunc func,
|
|
gconstpointer data);
|
|
void wp_core_register_object (WpCore * self, gpointer obj);
|
|
void wp_core_remove_object (WpCore * self, gpointer obj);
|
|
|
|
/* global */
|
|
|
|
typedef struct _WpGlobal WpGlobal;
|
|
struct _WpGlobal
|
|
{
|
|
guint32 id;
|
|
guint32 type;
|
|
guint32 version;
|
|
guint32 permissions;
|
|
WpProperties *properties;
|
|
GWeakRef proxy;
|
|
};
|
|
|
|
static inline WpGlobal *
|
|
wp_global_new (void)
|
|
{
|
|
WpGlobal *self = g_rc_box_new0 (WpGlobal);
|
|
g_weak_ref_init (&self->proxy, NULL);
|
|
return self;
|
|
}
|
|
|
|
static inline void
|
|
wp_global_clear (WpGlobal * self)
|
|
{
|
|
g_clear_pointer (&self->properties, wp_properties_unref);
|
|
g_weak_ref_clear (&self->proxy);
|
|
}
|
|
|
|
static inline WpGlobal *
|
|
wp_global_ref (WpGlobal * self)
|
|
{
|
|
return g_rc_box_acquire (self);
|
|
}
|
|
|
|
static inline void
|
|
wp_global_unref (WpGlobal * self)
|
|
{
|
|
g_rc_box_release_full (self, (GDestroyNotify) wp_global_clear);
|
|
}
|
|
|
|
G_DEFINE_AUTOPTR_CLEANUP_FUNC (WpGlobal, wp_global_unref)
|
|
|
|
/* object manager */
|
|
|
|
void wp_object_manager_add_global (WpObjectManager * self, WpGlobal * global);
|
|
void wp_object_manager_rm_global (WpObjectManager * self, guint32 id);
|
|
|
|
void wp_object_manager_add_object (WpObjectManager * self, GObject * object);
|
|
void wp_object_manager_rm_object (WpObjectManager * self, GObject * object);
|
|
|
|
/* proxy */
|
|
|
|
WpProxy * wp_proxy_new_global (WpCore * core, WpGlobal * global);
|
|
|
|
void wp_proxy_set_feature_ready (WpProxy * self, WpProxyFeatures feature);
|
|
void wp_proxy_augment_error (WpProxy * self, GError * error);
|
|
|
|
void wp_proxy_register_async_task (WpProxy * self, int seq, GTask * task);
|
|
GTask * wp_proxy_find_async_task (WpProxy * self, int seq, gboolean steal);
|
|
|
|
G_END_DECLS
|
|
|
|
#endif
|