Commit a63f2bb9 authored by George Kiagiadakis's avatar George Kiagiadakis

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.
parent 84b752e3
......@@ -7,30 +7,218 @@
*/
#include "core.h"
#include "proxy.h"
#include "wpenums.h"
enum {
SIGNAL_GLOBAL_ADDED,
SIGNAL_GLOBAL_REMOVED,
NUM_SIGNALS
#include <pipewire/pipewire.h>
/*
* Integration between the PipeWire main loop and GMainLoop
*/
#define WP_LOOP_SOURCE(x) ((WpLoopSource *) x)
typedef struct _WpLoopSource WpLoopSource;
struct _WpLoopSource
{
GSource parent;
struct pw_loop *loop;
};
static guint32 signals[NUM_SIGNALS];
static gboolean
wp_loop_source_dispatch (GSource * s, GSourceFunc callback, gpointer user_data)
{
int result;
struct global_object
pw_loop_enter (WP_LOOP_SOURCE(s)->loop);
result = pw_loop_iterate (WP_LOOP_SOURCE(s)->loop, 0);
pw_loop_leave (WP_LOOP_SOURCE(s)->loop);
if (G_UNLIKELY (result < 0))
g_warning ("pw_loop_iterate failed: %s", spa_strerror (result));
return G_SOURCE_CONTINUE;
}
static void
wp_loop_source_finalize (GSource * s)
{
GQuark key;
gpointer object;
GDestroyNotify destroy;
pw_loop_destroy (WP_LOOP_SOURCE(s)->loop);
}
static GSourceFuncs source_funcs = {
NULL,
NULL,
wp_loop_source_dispatch,
wp_loop_source_finalize
};
static GSource *
wp_loop_source_new (void)
{
GSource *s = g_source_new (&source_funcs, sizeof (WpLoopSource));
WP_LOOP_SOURCE(s)->loop = pw_loop_new (NULL);
g_source_add_unix_fd (s,
pw_loop_get_fd (WP_LOOP_SOURCE(s)->loop),
G_IO_IN | G_IO_ERR | G_IO_HUP);
return (GSource *) s;
}
/**
* WpCore
*/
struct _WpCore
{
GObject parent;
/* main loop integration */
GMainContext *context;
/* pipewire main objects */
struct pw_core *pw_core;
struct pw_remote *pw_remote;
struct spa_hook remote_listener;
/* remote core */
struct pw_core_proxy *core_proxy;
/* remote registry */
struct pw_registry_proxy *registry_proxy;
struct spa_hook registry_listener;
/* local proxies */
GHashTable *proxies;
GHashTable *default_features;
/* local global objects */
GPtrArray *global_objects;
};
struct global_object
{
GQuark key;
gpointer object;
GDestroyNotify destroy;
};
enum {
PROP_0,
PROP_CONTEXT,
PROP_PW_CORE,
PROP_PW_REMOTE,
PROP_REMOTE_STATE,
};
enum {
SIGNAL_REMOTE_STATE_CHANGED,
SIGNAL_GLOBAL_ADDED,
SIGNAL_GLOBAL_REMOVED,
SIGNAL_REMOTE_GLOBAL_ADDED,
SIGNAL_REMOTE_GLOBAL_REMOVED,
NUM_SIGNALS
};
static guint32 signals[NUM_SIGNALS];
G_DEFINE_TYPE (WpCore, wp_core, G_TYPE_OBJECT)
static void
on_proxy_ready (GObject * obj, GAsyncResult * res, gpointer data)
{
WpCore *self = WP_CORE (data);
WpProxy *proxy = WP_PROXY (obj);
g_autoptr (GError) error = NULL;
if (!wp_proxy_augment_finish (proxy, res, &error)) {
g_warning ("Failed to augment WpProxy (%p): %s", obj, error->message);
}
g_signal_emit (self, signals[SIGNAL_REMOTE_GLOBAL_ADDED],
wp_proxy_get_interface_quark (proxy), proxy);
}
static void
registry_global (void *data, uint32_t id, uint32_t permissions,
uint32_t type, uint32_t version, const struct spa_dict *props)
{
WpCore *self = WP_CORE (data);
WpProxy *proxy;
WpProxyFeatures features;
g_autoptr (WpProperties) properties = wp_properties_new_copy_dict (props);
/* construct & store WpProxy */
proxy = wp_proxy_new_global (self, id, permissions, properties,
type, version);
g_hash_table_insert (self->proxies, GUINT_TO_POINTER (id), proxy);
g_debug ("registry global:%u perm:0x%x type:%u/%u -> WpProxy:%p",
id, permissions, type, version, proxy);
/* augment */
features = GPOINTER_TO_UINT (g_hash_table_lookup (self->default_features,
GUINT_TO_POINTER (G_TYPE_FROM_INSTANCE (proxy))));
wp_proxy_augment (proxy, features, NULL, on_proxy_ready, self);
}
static void
registry_global_remove (void *data, uint32_t id)
{
WpCore *self = WP_CORE (data);
g_autoptr (WpProxy) proxy = NULL;
if (g_hash_table_steal_extended (self->proxies, GUINT_TO_POINTER (id), NULL,
(gpointer *) &proxy))
g_signal_emit (data, signals[SIGNAL_REMOTE_GLOBAL_REMOVED],
wp_proxy_get_interface_quark (proxy), proxy);
}
static const struct pw_registry_proxy_events registry_proxy_events = {
PW_VERSION_REGISTRY_PROXY_EVENTS,
.global = registry_global,
.global_remove = registry_global_remove,
};
static void
registry_init (WpCore *self)
{
/* Get the core proxy */
self->core_proxy = pw_remote_get_core_proxy (self->pw_remote);
/* Registry */
self->registry_proxy = pw_core_proxy_get_registry (self->core_proxy,
PW_VERSION_REGISTRY_PROXY, 0);
pw_registry_proxy_add_listener(self->registry_proxy, &self->registry_listener,
&registry_proxy_events, self);
}
static void
on_remote_state_changed (void *d, enum pw_remote_state old_state,
enum pw_remote_state new_state, const char *error)
{
WpCore *self = d;
GQuark detail;
g_debug ("pipewire remote state changed, old:%s new:%s",
pw_remote_state_as_string (old_state),
pw_remote_state_as_string (new_state));
/* Init the registry when connected */
if (!self->registry_proxy && new_state == PW_REMOTE_STATE_CONNECTED)
registry_init (self);
/* enum pw_remote_state matches values with WpRemoteState */
detail = g_quark_from_static_string (pw_remote_state_as_string (new_state));
g_signal_emit (self, signals[SIGNAL_REMOTE_STATE_CHANGED], detail, new_state);
}
static const struct pw_remote_events remote_events = {
PW_VERSION_REMOTE_EVENTS,
.state_changed = on_remote_state_changed,
};
static void
free_global_object (gpointer p)
{
......@@ -46,9 +234,29 @@ free_global_object (gpointer p)
static void
wp_core_init (WpCore * self)
{
self->proxies = g_hash_table_new_full (g_direct_hash, g_direct_equal, NULL,
g_object_unref);
self->default_features = g_hash_table_new (g_direct_hash, g_direct_equal);
self->global_objects = g_ptr_array_new_with_free_func (free_global_object);
}
static void
wp_core_constructed (GObject *object)
{
WpCore *self = WP_CORE (object);
g_autoptr (GSource) source = NULL;
source = wp_loop_source_new ();
g_source_attach (source, self->context);
self->pw_core = pw_core_new (WP_LOOP_SOURCE (source)->loop, NULL, 0);
self->pw_remote = pw_remote_new (self->pw_core, NULL, 0);
pw_remote_add_listener (self->pw_remote, &self->remote_listener,
&remote_events, self);
G_OBJECT_CLASS (wp_core_parent_class)->constructed (object);
}
static void
wp_core_dispose (GObject * obj)
{
......@@ -73,18 +281,98 @@ wp_core_dispose (GObject * obj)
static void
wp_core_finalize (GObject * obj)
{
WpCore *self = WP_CORE (obj);
g_clear_pointer (&self->proxies, g_hash_table_unref);
g_clear_pointer (&self->default_features, g_hash_table_unref);
g_clear_pointer (&self->pw_remote, pw_remote_destroy);
self->core_proxy= NULL;
self->registry_proxy = NULL;
g_clear_pointer (&self->pw_core, pw_core_destroy);
g_clear_pointer (&self->context, g_main_context_unref);
g_debug ("WpCore destroyed");
G_OBJECT_CLASS (wp_core_parent_class)->finalize (obj);
}
static void
wp_core_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec)
{
WpCore *self = WP_CORE (object);
switch (property_id) {
case PROP_CONTEXT:
g_value_set_boxed (value, self->context);
break;
case PROP_PW_CORE:
g_value_set_pointer (value, self->pw_core);
break;
case PROP_PW_REMOTE:
g_value_set_pointer (value, self->pw_remote);
break;
case PROP_REMOTE_STATE:
g_value_set_enum (value, wp_core_get_remote_state (self, NULL));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
wp_core_set_property (GObject * object, guint property_id,
const GValue * value, GParamSpec * pspec)
{
WpCore *self = WP_CORE (object);
switch (property_id) {
case PROP_CONTEXT:
self->context = g_value_dup_boxed (value);
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
wp_core_class_init (WpCoreClass * klass)
{
GObjectClass *object_class = (GObjectClass *) klass;
pw_init (NULL, NULL);
object_class->constructed = wp_core_constructed;
object_class->dispose = wp_core_dispose;
object_class->finalize = wp_core_finalize;
object_class->get_property = wp_core_get_property;
object_class->set_property = wp_core_set_property;
g_object_class_install_property (object_class, PROP_CONTEXT,
g_param_spec_boxed ("context", "context", "A GMainContext to attach to",
G_TYPE_MAIN_CONTEXT,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_PW_CORE,
g_param_spec_pointer ("pw-core", "pw-core", "The pipewire core",
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_PW_REMOTE,
g_param_spec_pointer ("pw-remote", "pw-remote", "The pipewire remote",
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_REMOTE_STATE,
g_param_spec_enum ("remote-state", "remote-state",
"The state of the remote",
WP_TYPE_REMOTE_STATE, WP_REMOTE_STATE_UNCONNECTED,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
/* Signals */
signals[SIGNAL_REMOTE_STATE_CHANGED] = g_signal_new ("remote-state-changed",
G_TYPE_FROM_CLASS (klass), G_SIGNAL_DETAILED | G_SIGNAL_RUN_LAST,
0, NULL, NULL, NULL, G_TYPE_NONE, 1, WP_TYPE_REMOTE_STATE);
signals[SIGNAL_GLOBAL_ADDED] = g_signal_new ("global-added",
G_TYPE_FROM_CLASS (klass), G_SIGNAL_DETAILED | G_SIGNAL_RUN_LAST, 0, NULL,
......@@ -93,12 +381,117 @@ wp_core_class_init (WpCoreClass * klass)
signals[SIGNAL_GLOBAL_REMOVED] = g_signal_new ("global-removed",
G_TYPE_FROM_CLASS (klass), G_SIGNAL_DETAILED | G_SIGNAL_RUN_LAST, 0, NULL,
NULL, NULL, G_TYPE_NONE, 2, G_TYPE_UINT, G_TYPE_POINTER);
signals[SIGNAL_REMOTE_GLOBAL_ADDED] = g_signal_new ("remote-global-added",
G_TYPE_FROM_CLASS (klass), G_SIGNAL_DETAILED | G_SIGNAL_RUN_LAST,
0, NULL, NULL, NULL, G_TYPE_NONE, 1, WP_TYPE_PROXY);
signals[SIGNAL_REMOTE_GLOBAL_REMOVED] = g_signal_new ("remote-global-removed",
G_TYPE_FROM_CLASS (klass), G_SIGNAL_DETAILED | G_SIGNAL_RUN_LAST,
0, NULL, NULL, NULL, G_TYPE_NONE, 1, WP_TYPE_PROXY);
}
WpCore *
wp_core_new (void)
wp_core_new (GMainContext *context)
{
return g_object_new (WP_TYPE_CORE, "context", context, NULL);
}
GMainContext *
wp_core_get_context (WpCore * self)
{
g_return_val_if_fail (WP_IS_CORE (self), NULL);
return self->context;
}
struct pw_core *
wp_core_get_pw_core (WpCore * self)
{
return g_object_new (WP_TYPE_CORE, NULL);
g_return_val_if_fail (WP_IS_CORE (self), NULL);
return self->pw_core;
}
struct pw_remote *
wp_core_get_pw_remote (WpCore * self)
{
g_return_val_if_fail (WP_IS_CORE (self), NULL);
return self->pw_remote;
}
static gboolean
connect_in_idle (WpCore *self)
{
pw_remote_connect (self->pw_remote);
return G_SOURCE_REMOVE;
}
gboolean
wp_core_connect (WpCore *self)
{
g_autoptr (GSource) source = NULL;
g_return_val_if_fail (WP_IS_CORE (self), FALSE);
source = g_idle_source_new ();
g_source_set_callback (source, (GSourceFunc) connect_in_idle, self, NULL);
g_source_attach (source, self->context);
return TRUE;
}
WpRemoteState
wp_core_get_remote_state (WpCore * self, const gchar ** error)
{
g_return_val_if_fail (WP_IS_CORE (self), WP_REMOTE_STATE_UNCONNECTED);
/* enum pw_remote_state matches values with WpRemoteState */
G_STATIC_ASSERT ((gint) WP_REMOTE_STATE_ERROR == (gint) PW_REMOTE_STATE_ERROR);
G_STATIC_ASSERT ((gint) WP_REMOTE_STATE_UNCONNECTED == (gint) PW_REMOTE_STATE_UNCONNECTED);
G_STATIC_ASSERT ((gint) WP_REMOTE_STATE_CONNECTING == (gint) PW_REMOTE_STATE_CONNECTING);
G_STATIC_ASSERT ((gint) WP_REMOTE_STATE_CONNECTED == (gint) PW_REMOTE_STATE_CONNECTED);
return (WpRemoteState) pw_remote_get_state (self->pw_remote, error);
}
void
wp_core_set_default_proxy_features (WpCore * self,
GType proxy_type, WpProxyFeatures features)
{
g_return_if_fail (WP_IS_CORE (self));
g_hash_table_insert (self->default_features, GUINT_TO_POINTER (proxy_type),
GUINT_TO_POINTER (features));
}
WpProxy *
wp_core_create_remote_object (WpCore *self,
const gchar *factory_name, guint32 interface_type,
guint32 interface_version, WpProperties * properties)
{
struct pw_proxy *pw_proxy;
g_return_val_if_fail (WP_IS_CORE (self), NULL);
g_return_val_if_fail (self->core_proxy, NULL);
pw_proxy = pw_core_proxy_create_object (self->core_proxy, factory_name,
interface_type, interface_version,
properties ? wp_properties_peek_dict (properties) : NULL, 0);
return wp_proxy_new_wrap (self, pw_proxy, interface_type,
interface_version);
}
struct pw_core_proxy *
wp_core_get_pw_core_proxy (WpCore * self)
{
g_return_val_if_fail (WP_IS_CORE (self), NULL);
return self->core_proxy;
}
struct pw_registry_proxy *
wp_core_get_pw_registry_proxy (WpCore * self)
{
g_return_val_if_fail (WP_IS_CORE (self), NULL);
return self->registry_proxy;
}
/**
......@@ -229,4 +622,3 @@ G_DEFINE_QUARK (endpoint, wp_global_endpoint)
G_DEFINE_QUARK (factory, wp_global_factory)
G_DEFINE_QUARK (module, wp_global_module)
G_DEFINE_QUARK (policy-manager, wp_global_policy_manager)
G_DEFINE_QUARK (remote-pipewire, wp_global_remote_pipewire)
......@@ -10,12 +10,57 @@
#define __WIREPLUMBER_CORE_H__
#include <glib-object.h>
#include "proxy.h"
G_BEGIN_DECLS
struct pw_core;
struct pw_remote;
/**
* WpRemoteState:
* @WP_REMOTE_STATE_ERROR: remote is in error
* @WP_REMOTE_STATE_UNCONNECTED: not connected
* @WP_REMOTE_STATE_CONNECTING: connecting to remote service
* @WP_REMOTE_STATE_CONNECTED: remote is connected and ready
*
* The different states the remote can be
*/
typedef enum {
WP_REMOTE_STATE_ERROR = -1,
WP_REMOTE_STATE_UNCONNECTED = 0,
WP_REMOTE_STATE_CONNECTING = 1,
WP_REMOTE_STATE_CONNECTED = 2,
} WpRemoteState;
#define WP_TYPE_CORE (wp_core_get_type ())
G_DECLARE_FINAL_TYPE (WpCore, wp_core, WP, CORE, GObject)
WpCore * wp_core_new (GMainContext *context);
GMainContext * wp_core_get_context (WpCore * self);
struct pw_core * wp_core_get_pw_core (WpCore * self);
struct pw_remote * wp_core_get_pw_remote (WpCore * self);
gboolean wp_core_connect (WpCore * self);
WpRemoteState wp_core_get_remote_state (WpCore * self, const gchar ** error);
void wp_core_set_default_proxy_features (
WpCore * self, GType proxy_type, WpProxyFeatures features);
WpProxy * wp_core_create_remote_object (WpCore * self,
const gchar * factory_name, guint32 interface_type,
guint32 interface_version, WpProperties * properties);
/* private */
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);
enum {
WP_CORE_FOREACH_GLOBAL_DONE = FALSE,
WP_CORE_FOREACH_GLOBAL_CONTINUE = TRUE,
......@@ -24,8 +69,6 @@ enum {
typedef gboolean (*WpCoreForeachGlobalFunc) (GQuark key, gpointer global,
gpointer user_data);
WpCore * wp_core_new (void);
gpointer wp_core_get_global (WpCore * self, GQuark key);
void wp_core_foreach_global (WpCore * self, WpCoreForeachGlobalFunc callback,
gpointer user_data);
......@@ -46,14 +89,6 @@ GQuark wp_global_module_quark (void);
#define WP_GLOBAL_POLICY_MANAGER (wp_global_policy_manager_quark ())
GQuark wp_global_policy_manager_quark (void);
/**
* WP_GLOBAL_REMOTE_PIPEWIRE:
* The key to access the #WpRemote global object that maintains
* the connection to pipewire
*/
#define WP_GLOBAL_REMOTE_PIPEWIRE (wp_global_remote_pipewire_quark ())
GQuark wp_global_remote_pipewire_quark (void);
G_END_DECLS
#endif
......@@ -11,8 +11,6 @@ wp_lib_sources = [
'proxy-link.c',
'proxy-node.c',
'proxy-port.c',
'remote.c',
'remote-pipewire.c',
]
wp_lib_headers = [
......@@ -28,8 +26,6 @@ wp_lib_headers = [
'proxy-node.h',
'proxy-port.h',
'proxy-link.h',
'remote.h',
'remote-pipewire.h',
'wp.h',
]
......
......@@ -8,8 +8,8 @@
*/
#include "proxy.h"
#include "core.h"
#include "error.h"
#include "remote-pipewire.h"
#include "wpenums.h"
#include "proxy-client.h"
......@@ -24,7 +24,7 @@ typedef struct _WpProxyPrivate WpProxyPrivate;
struct _WpProxyPrivate
{
/* properties */
GWeakRef remote;
GWeakRef core;
guint32 global_id;
guint32 global_perm;
......@@ -48,7 +48,7 @@ struct _WpProxyPrivate
enum {
PROP_0,
PROP_REMOTE,
PROP_CORE,
PROP_GLOBAL_ID,
PROP_GLOBAL_PERMISSIONS,
PROP_GLOBAL_PROPERTIES,
......@@ -194,7 +194,7 @@ wp_proxy_init (WpProxy * self)
{
WpProxyPrivate *priv = wp_proxy_get_instance_private (self);
g_weak_ref_init (&priv->remote, NULL);
g_weak_ref_init (&priv->core, NULL);
priv->async_tasks = g_hash_table_new_full (g_direct_hash, g_direct_equal,
NULL, g_object_unref);
}
......@@ -221,7 +221,7 @@ wp_proxy_finalize (GObject * object)
g_clear_object (&priv->task);
g_clear_pointer (&priv->global_props, wp_properties_unref);
g_clear_pointer (&priv->pw_proxy, pw_proxy_destroy);
g_weak_ref_clear (&priv->remote);
g_weak_ref_clear (&priv->core);
g_clear_pointer (&priv->async_tasks, g_hash_table_unref);
G_OBJECT_CLASS (wp_proxy_parent_class)->finalize (object);
......@@ -234,8 +234,8 @@ wp_proxy_set_property (GObject * object, guint property_id,
WpProxyPrivate *priv = wp_proxy_get_instance_private (WP_PROXY(object));
switch (property_id) {
case PROP_REMOTE:
g_weak_ref_set (&priv->remote, g_value_get_object (value));
case PROP_CORE:
g_weak_ref_set (&priv->core, g_value_get_object (value));
break;
case PROP_GLOBAL_ID:
priv->global_id = g_value_get_uint (value);
......@@ -268,8 +268,8 @@ wp_proxy_get_property (GObject * object, guint property_id, GValue * value,
WpProxyPrivate *priv = wp_proxy_get_instance_private (WP_PROXY(object));
switch (property_id) {
case PROP_REMOTE:
g_value_take_object (value, g_weak_ref_get (&priv->remote));
case PROP_CORE:
g_value_take_object (value, g_weak_ref_get (&priv->core));
break;
case PROP_GLOBAL_ID:
g_value_set_uint (value, priv->global_id);
......@@ -309,7 +309,7 @@ static void
wp_proxy_default_augment (WpProxy * self, WpProxyFeatures features)
{
WpProxyPrivate *priv = wp_proxy_get_instance_private (self);
g_autoptr (WpRemote) remote = NULL;
g_autoptr (WpCore) core = NULL;
/* ensure we have a pw_proxy, as we can't have
* any other feature without first having that */
......@@ -327,13 +327,13 @@ wp_proxy_default_augment (WpProxy * self, WpProxyFeatures features)
return;
}
remote = g_weak_ref_get (&priv->remote);
g_return_if_fail (remote);
core = g_weak_ref_get (&priv->core);
g_return_if_fail (core);
/* bind */
priv->pw_proxy = wp_remote_pipewire_proxy_bind (
WP_REMOTE_PIPEWIRE (remote),
priv->global_id, priv->iface_type);
priv->pw_proxy = pw_registry_proxy_bind (
wp_core_get_pw_registry_proxy (core), priv->global_id,
priv->iface_type, priv->iface_version, 0);
wp_proxy_got_pw_proxy (self);
}
}
......@@ -352,9 +352,8 @@ wp_proxy_class_init (WpProxyClass * klass)
/* Install the properties */
g_object_class_install_property (object_class, PROP_REMOTE,
g_param_spec_object ("remote", "remote",
"The pipewire connection WpRemote", WP_TYPE_REMOTE,
g_object_class_install_property (object_class, PROP_CORE,
g_param_spec_object ("core", "core", "The WpCore", WP_TYPE_CORE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_GLOBAL_ID,
......@@ -414,13 +413,13 @@ wp_proxy_class_init (WpProxyClass * klass)
}
WpProxy *
wp_proxy_new_global (WpRemote * remote,
wp_proxy_new_global (WpCore * core,
guint32 id, guint32 permissions, WpProperties * properties,
guint32 type, guint32 version)
{
GType gtype = wp_proxy_find_instance_type (type, version);
return g_object_new (gtype,
"remote", remote,
"core", core,
"global-id", id,
"global-permissions", permissions,
"global-properties", properties,
......@@ -430,12 +429,12 @@ wp_proxy_new_global (WpRemote * remote,
}
WpProxy *
wp_proxy_new_wrap (WpRemote * remote,
wp_proxy_new_wrap (WpCore * core,
struct pw_proxy * proxy, guint32 type, guint32 version)
{
GType gtype = wp_proxy_find_instance_type (type, version);
return g_object_new (gtype,
"remote", remote,
"core", core,
"pw-proxy", proxy,
"interface-type", type,
"interface-version", version,
......@@ -544,20 +543,20 @@ wp_proxy_get_features (WpProxy * self)
}
/**
* wp_proxy_get_remote:
* wp_proxy_get_core:
* @self: the proxy
*
* Returns: (transfer full): the remote that created this proxy
* Returns: (transfer full): the core that created this proxy
*/
WpRemote *
wp_proxy_get_remote (WpProxy * self)
WpCore *
wp_proxy_get_core (WpProxy * self)
{
WpProxyPrivate *priv;
g_return_val_if_fail (WP_IS_PROXY (self), NULL);
priv = wp_proxy_get_instance_private (self);
return g_weak_ref_get (&priv->remote);
return g_weak_ref_get (&priv->core);
}
gboolean
......
......@@ -12,12 +12,12 @@
#include <gio/gio.h>
#include "remote.h"
#include "properties.h"
G_BEGIN_DECLS
struct pw_proxy;
typedef struct _WpCore WpCore;