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
This diff is collapsed.
......@@ -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;
typedef enum { /*< flags >*/
WP_PROXY_FEATURE_PW_PROXY = (1 << 0),
......@@ -40,10 +40,10 @@ struct _WpProxyClass
void (*pw_proxy_destroyed) (WpProxy * self);
};
WpProxy * wp_proxy_new_global (WpRemote * remote,
WpProxy * wp_proxy_new_global (WpCore * core,
guint32 id, guint32 permissions, WpProperties * properties,
guint32 type, guint32 version);
WpProxy * wp_proxy_new_wrap (WpRemote * remote,
WpProxy * wp_proxy_new_wrap (WpCore * core,
struct pw_proxy * proxy, guint32 type, guint32 version);
void wp_proxy_augment (WpProxy *self,
......@@ -54,7 +54,7 @@ gboolean wp_proxy_augment_finish (WpProxy * self, GAsyncResult * res,
WpProxyFeatures wp_proxy_get_features (WpProxy * self);
WpRemote * wp_proxy_get_remote (WpProxy * self);
WpCore * wp_proxy_get_core (WpProxy * self);
gboolean wp_proxy_is_global (WpProxy * self);
guint32 wp_proxy_get_global_id (WpProxy * self);
......
This diff is collapsed.
/* WirePlumber
*
* Copyright © 2019 Collabora Ltd.
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
*
* SPDX-License-Identifier: MIT
*/
#ifndef __WIREPLUMBER_REMOTE_PIPEWIRE_H__
#define __WIREPLUMBER_REMOTE_PIPEWIRE_H__
#include "remote.h"
#include "proxy.h"
G_BEGIN_DECLS
#define WP_TYPE_REMOTE_PIPEWIRE (wp_remote_pipewire_get_type ())
G_DECLARE_FINAL_TYPE (WpRemotePipewire, wp_remote_pipewire,
WP, REMOTE_PIPEWIRE, WpRemote)
WpRemote *wp_remote_pipewire_new (WpCore *core, GMainContext *context);
void wp_remote_pipewire_set_default_features (
WpRemotePipewire * self, GType proxy_type, WpProxyFeatures features);
WpProxy * wp_remote_pipewire_create_object (WpRemotePipewire *self,
const gchar *factory_name, guint32 interface_type,
guint32 interface_version, WpProperties * properties);
gpointer wp_remote_pipewire_proxy_bind (WpRemotePipewire *self, guint global_id,
guint global_type);
gpointer wp_remote_pipewire_find_factory (WpRemotePipewire *self,
const char *factory_name);
void wp_remote_pipewire_add_spa_lib (WpRemotePipewire *self,
const char *factory_regexp, const char *lib);
gpointer wp_remote_pipewire_load_spa_handle(WpRemotePipewire *self,
const char *factory_name, gconstpointer info);
gpointer wp_remote_pipewire_export (WpRemotePipewire *self, guint type,
gpointer props, gpointer object, size_t user_data_size);
gpointer wp_remote_pipewire_module_load (WpRemotePipewire *self,
const char *name, const char *args, gpointer properties);
G_END_DECLS
#endif
/* WirePlumber
*
* Copyright © 2019 Collabora Ltd.
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
*
* SPDX-License-Identifier: MIT
*/
#include "remote.h"
#include "wpenums.h"
enum {
PROP_0,
PROP_CORE,
PROP_STATE,
PROP_ERROR_MESSAGE,
};
enum {
SIGNAL_STATE_CHANGED,
N_SIGNALS
};
static guint signals[N_SIGNALS];
typedef struct _WpRemotePrivate WpRemotePrivate;
struct _WpRemotePrivate
{
GWeakRef core;
};
G_DEFINE_ABSTRACT_TYPE_WITH_PRIVATE (WpRemote, wp_remote, G_TYPE_OBJECT)
static void
wp_remote_init (WpRemote *self)
{
WpRemotePrivate *priv = wp_remote_get_instance_private (self);
g_weak_ref_init (&priv->core, NULL);
}
static void
wp_remote_finalize (GObject *object)
{
WpRemotePrivate *priv = wp_remote_get_instance_private (WP_REMOTE (object));
g_weak_ref_clear (&priv->core);
g_debug ("%s destroyed", G_OBJECT_TYPE_NAME (object));
G_OBJECT_CLASS (wp_remote_parent_class)->finalize (object);
}
static void
wp_remote_set_property (GObject * object, guint property_id,
const GValue * value, GParamSpec * pspec)
{
WpRemotePrivate *priv = wp_remote_get_instance_private (WP_REMOTE (object));
switch (property_id) {
case PROP_CORE:
g_weak_ref_set (&priv->core, g_value_get_object (value));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
wp_remote_get_property (GObject * object, guint property_id,
GValue * value, GParamSpec * pspec)
{
WpRemotePrivate *priv = wp_remote_get_instance_private (WP_REMOTE (object));
switch (property_id) {
case PROP_CORE:
g_value_take_object (value, g_weak_ref_get (&priv->core));
break;
default:
G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec);
break;
}
}
static void
wp_remote_notify (GObject *object, GParamSpec *param)
{
if (!g_strcmp0 (param->name, "state")) {
WpRemoteState state;
GParamSpecEnum *param_enum = (GParamSpecEnum *) param;
GEnumValue *value;
GQuark detail;
g_object_get (object, "state", &state, NULL);
value = g_enum_get_value (param_enum->enum_class, state);
detail = g_quark_from_static_string (value->value_nick);
g_signal_emit (object, signals[SIGNAL_STATE_CHANGED], detail, state);
}
if (G_OBJECT_CLASS (wp_remote_parent_class)->notify)
G_OBJECT_CLASS (wp_remote_parent_class)->notify (object, param);
}
static void
wp_remote_class_init (WpRemoteClass *klass)
{
GObjectClass *object_class = (GObjectClass *) klass;
object_class->finalize = wp_remote_finalize;
object_class->set_property = wp_remote_set_property;
object_class->get_property = wp_remote_get_property;
object_class->notify = wp_remote_notify;
g_object_class_install_property (object_class, PROP_CORE,
g_param_spec_object ("core", "core", "The wireplumber core",
WP_TYPE_CORE,
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_STATE,
g_param_spec_enum ("state", "state", "The state of the remote",
WP_TYPE_REMOTE_STATE, WP_REMOTE_STATE_UNCONNECTED,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
g_object_class_install_property (object_class, PROP_ERROR_MESSAGE,
g_param_spec_string ("error-message", "error-message",
"The last error message of the remote", NULL,
G_PARAM_READABLE | G_PARAM_STATIC_STRINGS));
signals[SIGNAL_STATE_CHANGED] = g_signal_new ("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);
}
/**
* wp_remote_get_core:
* @self: the remote
*
* Returns: (transfer full): the core of the remote
*/
WpCore *
wp_remote_get_core (WpRemote *self)
{
WpRemotePrivate *priv = wp_remote_get_instance_private (self);
return g_weak_ref_get (&priv->core);
}
gboolean
wp_remote_connect (WpRemote *self)
{
if (WP_REMOTE_GET_CLASS (self)->connect)
return WP_REMOTE_GET_CLASS (self)->connect (self);
return FALSE;
}
/* WirePlumber
*
* Copyright © 2019 Collabora Ltd.
* @author George Kiagiadakis <george.kiagiadakis@collabora.com>
*
* SPDX-License-Identifier: MIT
*/
#ifndef __WIREPLUMBER_REMOTE_H__
#define __WIREPLUMBER_REMOTE_H__
#include "core.h"
G_BEGIN_DECLS
/**
* 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_REMOTE (wp_remote_get_type ())
G_DECLARE_DERIVABLE_TYPE (WpRemote, wp_remote, WP, REMOTE, GObject)
struct _WpRemoteClass
{
GObjectClass parent_class;
gboolean (*connect) (WpRemote *self);
};
WpCore *wp_remote_get_core (WpRemote *self);
gboolean wp_remote_connect (WpRemote *self);
G_END_DECLS
#endif
......@@ -18,5 +18,3 @@
#include "proxy-link.h"
#include "proxy-node.h"
#include "proxy-port.h"
#include "remote.h"
#include "remote-pipewire.h"
......@@ -10,7 +10,7 @@
#include <pipewire/pipewire.h>
static void
client_added (WpRemote * remote, WpProxyClient *client, gpointer data)
client_added (WpCore * core, WpProxyClient *client, gpointer data)
{
g_autoptr (WpProperties) properties = NULL;
const char *access;
......@@ -30,12 +30,9 @@ client_added (WpRemote * remote, WpProxyClient *client, gpointer data)
void
wireplumber__module_init (WpModule * module, WpCore * core, GVariant * args)
{
WpRemote *remote = wp_core_get_global (core, WP_GLOBAL_REMOTE_PIPEWIRE);
g_return_if_fail (remote != NULL);
wp_core_set_default_proxy_features (core, WP_TYPE_PROXY_CLIENT,
WP_PROXY_FEATURE_PW_PROXY | WP_PROXY_FEATURE_INFO);
wp_remote_pipewire_set_default_features (WP_REMOTE_PIPEWIRE (remote),
WP_TYPE_PROXY_CLIENT, WP_PROXY_FEATURE_PW_PROXY | WP_PROXY_FEATURE_INFO);
g_signal_connect(remote, "global-added::client", (GCallback) client_added,
NULL);
g_signal_connect(core, "remote-global-added::client",
(GCallback) client_added, NULL);
}
......@@ -298,9 +298,8 @@ mixer_endpoint_class_init (WpMixerEndpointClass * klass)
}
static void
remote_connected (WpRemote *remote, WpRemoteState state, GVariant *streams)
remote_connected (WpCore *core, WpRemoteState state, GVariant *streams)
{
g_autoptr (WpCore) core = wp_remote_get_core (remote);
g_autoptr (WpEndpoint) ep = g_object_new (mixer_endpoint_get_type (),
"core", core,
"name", "Mixer",
......@@ -313,15 +312,11 @@ remote_connected (WpRemote *remote, WpRemoteState state, GVariant *streams)
void
wireplumber__module_init (WpModule * module, WpCore * core, GVariant * args)
{
WpRemote *remote;
GVariant *streams;
remote = wp_core_get_global (core, WP_GLOBAL_REMOTE_PIPEWIRE);
g_return_if_fail (remote != NULL);
streams = g_variant_lookup_value (args, "streams", G_VARIANT_TYPE ("as"));
g_signal_connect_data (remote, "state-changed::connected",
g_signal_connect_data (core, "remote-state-changed::connected",
(GCallback) remote_connected, streams, (GClosureNotify) g_variant_unref,
0);
}
......@@ -23,20 +23,10 @@ void simple_endpoint_link_factory (WpFactory * factory, GType type,
void
wireplumber__module_init (WpModule * module, WpCore * core, GVariant * args)
{
WpRemotePipewire *rp;
struct pw_core *pw_core = wp_core_get_pw_core (core);
/* Get the remote pipewire */
rp = wp_core_get_global (core, WP_GLOBAL_REMOTE_PIPEWIRE);
if (!rp) {
g_critical ("module-pipewire cannot be loaded without a registered "
"WpRemotePipewire object");
return;
}
/* Load the client-device and adapter modules */
wp_remote_pipewire_module_load(rp, "libpipewire-module-client-device", NULL,
NULL);
wp_remote_pipewire_module_load(rp, "libpipewire-module-adapter", NULL, NULL);
pw_module_load (pw_core, "libpipewire-module-client-device", NULL, NULL);
pw_module_load (pw_core, "libpipewire-module-adapter", NULL, NULL);
/* Register simple-endpoint and simple-endpoint-link */
wp_factory_new (core, "pipewire-simple-endpoint",
......
......@@ -167,7 +167,6 @@ simple_endpoint_link_create (WpEndpointLink * epl, GVariant * src_data,
{
WpPipewireSimpleEndpointLink *self = WP_PIPEWIRE_SIMPLE_ENDPOINT_LINK(epl);
g_autoptr (WpCore) core = NULL;
WpRemotePipewire *remote_pipewire;
guint32 output_node_id, input_node_id;
GVariant *src_ports, *sink_ports;
GVariantIter *out_iter, *in_iter;
......@@ -179,10 +178,6 @@ simple_endpoint_link_create (WpEndpointLink * epl, GVariant * src_data,
core = g_weak_ref_get (&self->core);
g_return_val_if_fail (core, FALSE);
/* Get the remote pipewire */
remote_pipewire = wp_core_get_global (core, WP_GLOBAL_REMOTE_PIPEWIRE);
g_return_val_if_fail (remote_pipewire, FALSE);
/* Get the node ids and port ids */
if (!g_variant_lookup (src_data, "node-id", "u", &output_node_id))
return FALSE;
......@@ -226,7 +221,7 @@ simple_endpoint_link_create (WpEndpointLink * epl, GVariant * src_data,
wp_properties_setf(props, PW_KEY_LINK_INPUT_PORT, "%d", in_id);
/* Create the link */
proxy = wp_remote_pipewire_create_object(remote_pipewire, "link-factory",
proxy = wp_core_create_remote_object(core, "link-factory",
PW_TYPE_INTERFACE_Link, PW_VERSION_LINK_PROXY, props);
g_return_val_if_fail (proxy, FALSE);
g_ptr_array_add(self->link_proxies, proxy);
......
......@@ -32,9 +32,6 @@ struct _WpPipewireSimpleEndpoint
/* The task to signal the endpoint is initialized */
GTask *init_task;
/* The remote pipewire */
WpRemotePipewire *remote_pipewire;
/* Proxies */
WpProxyNode *proxy_node;
GPtrArray *proxies_port;
......@@ -175,7 +172,7 @@ on_proxy_port_augmented (WpProxy *proxy, GAsyncResult *res,
}
static void
on_port_added(WpRemotePipewire *rp, WpProxy *proxy, gpointer d)
on_port_added (WpCore *core, WpProxy *proxy, gpointer d)
{
WpPipewireSimpleEndpoint *self = d;
const char *s;
......@@ -287,10 +284,8 @@ wp_simple_endpoint_init_async (GAsyncInitable *initable, int io_priority,
self->init_task = g_task_new (initable, cancellable, callback, data);
/* Register a port_added callback */
self->remote_pipewire = wp_core_get_global (core, WP_GLOBAL_REMOTE_PIPEWIRE);
g_return_if_fail(self->remote_pipewire);
g_signal_connect_object(self->remote_pipewire, "global-added::port",
(GCallback)on_port_added, self, 0);
g_signal_connect_object (core, "remote-global-added::port",
(GCallback) on_port_added, self, 0);
/* Augment to get the info */
wp_proxy_augment (WP_PROXY (self->proxy_node),
......
......@@ -26,7 +26,6 @@ struct monitor {
struct impl
{
WpModule *module;
WpRemotePipewire *remote_pipewire;
GHashTable *registered_endpoints;
GVariant *streams;
......@@ -171,9 +170,8 @@ is_alsa_node (WpProperties * props)
}
static void
on_node_added(WpRemotePipewire *rp, WpProxy *proxy, struct impl *impl)
on_node_added(WpCore *core, WpProxy *proxy, struct impl *impl)
{
g_autoptr (WpCore) core = wp_module_get_core (impl->module);
const gchar *media_class, *name;
enum pw_direction direction;
GVariantBuilder b;
......@@ -214,7 +212,7 @@ on_node_added(WpRemotePipewire *rp, WpProxy *proxy, struct impl *impl)
}
static void
on_global_removed (WpRemotePipewire *rp, WpProxy *proxy, struct impl *impl)
on_node_removed (WpCore *core, WpProxy *proxy, struct impl *impl)
{
WpEndpoint *endpoint = NULL;
guint32 id = wp_proxy_get_global_id (proxy);
......@@ -237,6 +235,7 @@ create_node(struct impl *impl, struct device *dev, uint32_t id,
struct node *node;
const char *name;
g_autoptr (WpProperties) props = NULL;
g_autoptr (WpCore) core = wp_module_get_core (impl->module);
/* Check if the type is a node */
if (info->type != SPA_TYPE_INTERFACE_Node)
......@@ -264,8 +263,8 @@ create_node(struct impl *impl, struct device *dev, uint32_t id,
node->impl = impl;
node->device = dev;
node->id = id;
node->proxy = wp_remote_pipewire_create_object (impl->remote_pipewire,
"adapter", PW_TYPE_INTERFACE_Node, PW_VERSION_NODE_PROXY, props);
node->proxy = wp_core_create_remote_object (core, "adapter",
PW_TYPE_INTERFACE_Node, PW_VERSION_NODE_PROXY, props);
if (!node->proxy) {
g_slice_free (struct node, node);
return NULL;
......@@ -348,8 +347,9 @@ static const struct spa_device_events device_events = {
static struct device*
create_device(struct impl *impl, uint32_t id,
const struct spa_monitor_object_info *info) {
const struct spa_monitor_object_info *info)
{
g_autoptr (WpCore) core = wp_module_get_core