proxy: add global_id property
This commit is contained in:
@@ -104,11 +104,12 @@ wp_proxy_node_class_init (WpProxyNodeClass * klass)
|
||||
}
|
||||
|
||||
void
|
||||
wp_proxy_node_new (gpointer proxy, GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
wp_proxy_node_new (guint global_id, gpointer proxy,
|
||||
GAsyncReadyCallback callback, gpointer user_data)
|
||||
{
|
||||
g_async_initable_new_async (
|
||||
WP_TYPE_PROXY_NODE, G_PRIORITY_DEFAULT, NULL, callback, user_data,
|
||||
"global-id", global_id,
|
||||
"pw-proxy", proxy,
|
||||
NULL);
|
||||
}
|
||||
|
@@ -17,8 +17,8 @@ G_BEGIN_DECLS
|
||||
#define WP_TYPE_PROXY_NODE (wp_proxy_node_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (WpProxyNode, wp_proxy_node, WP, PROXY_NODE, WpProxy)
|
||||
|
||||
void wp_proxy_node_new (gpointer proxy, GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
void wp_proxy_node_new (guint global_id, gpointer proxy,
|
||||
GAsyncReadyCallback callback, gpointer user_data);
|
||||
WpProxyNode *wp_proxy_node_new_finish(GObject *initable, GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
|
@@ -138,11 +138,12 @@ wp_proxy_port_class_init (WpProxyPortClass * klass)
|
||||
}
|
||||
|
||||
void
|
||||
wp_proxy_port_new (gpointer proxy, GAsyncReadyCallback callback,
|
||||
gpointer user_data)
|
||||
wp_proxy_port_new (guint global_id, gpointer proxy,
|
||||
GAsyncReadyCallback callback, gpointer user_data)
|
||||
{
|
||||
g_async_initable_new_async (
|
||||
WP_TYPE_PROXY_PORT, G_PRIORITY_DEFAULT, NULL, callback, user_data,
|
||||
"global-id", global_id,
|
||||
"pw-proxy", proxy,
|
||||
NULL);
|
||||
}
|
||||
|
@@ -17,8 +17,8 @@ G_BEGIN_DECLS
|
||||
#define WP_TYPE_PROXY_PORT (wp_proxy_port_get_type ())
|
||||
G_DECLARE_FINAL_TYPE (WpProxyPort, wp_proxy_port, WP, PROXY_PORT, WpProxy)
|
||||
|
||||
void wp_proxy_port_new (gpointer proxy, GAsyncReadyCallback callback,
|
||||
gpointer user_data);
|
||||
void wp_proxy_port_new (guint global_id, gpointer proxy,
|
||||
GAsyncReadyCallback callback, gpointer user_data);
|
||||
WpProxyPort *wp_proxy_port_new_finish(GObject *initable, GAsyncResult *res,
|
||||
GError **error);
|
||||
|
||||
|
@@ -13,6 +13,9 @@
|
||||
typedef struct _WpProxyPrivate WpProxyPrivate;
|
||||
struct _WpProxyPrivate
|
||||
{
|
||||
/* The global id */
|
||||
guint global_id;
|
||||
|
||||
/* The proxy */
|
||||
struct pw_proxy *proxy;
|
||||
|
||||
@@ -25,6 +28,7 @@ struct _WpProxyPrivate
|
||||
|
||||
enum {
|
||||
PROP_0,
|
||||
PROP_GLOBAL_ID,
|
||||
PROP_PROXY,
|
||||
};
|
||||
|
||||
@@ -104,6 +108,9 @@ wp_proxy_set_property (GObject * object, guint property_id,
|
||||
WpProxyPrivate *self = wp_proxy_get_instance_private (WP_PROXY(object));
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_GLOBAL_ID:
|
||||
self->global_id = g_value_get_uint (value);
|
||||
break;
|
||||
case PROP_PROXY:
|
||||
self->proxy = g_value_get_pointer (value);
|
||||
break;
|
||||
@@ -120,6 +127,9 @@ wp_proxy_get_property (GObject * object, guint property_id, GValue * value,
|
||||
WpProxyPrivate *self = wp_proxy_get_instance_private (WP_PROXY(object));
|
||||
|
||||
switch (property_id) {
|
||||
case PROP_GLOBAL_ID:
|
||||
g_value_set_uint (value, self->global_id);
|
||||
break;
|
||||
case PROP_PROXY:
|
||||
g_value_set_pointer (value, self->proxy);
|
||||
break;
|
||||
@@ -178,6 +188,10 @@ wp_proxy_class_init (WpProxyClass * klass)
|
||||
object_class->set_property = wp_proxy_set_property;
|
||||
|
||||
/* Install the properties */
|
||||
g_object_class_install_property (object_class, PROP_GLOBAL_ID,
|
||||
g_param_spec_uint ("global-id", "global-id", "The pipewire global id",
|
||||
0, G_MAXUINT, 0,
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
||||
g_object_class_install_property (object_class, PROP_PROXY,
|
||||
g_param_spec_pointer ("pw-proxy", "pw-proxy", "The pipewire proxy",
|
||||
G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS));
|
||||
@@ -189,6 +203,17 @@ wp_proxy_class_init (WpProxyClass * klass)
|
||||
g_cclosure_marshal_VOID__VOID, G_TYPE_NONE, 0);
|
||||
}
|
||||
|
||||
guint
|
||||
wp_proxy_get_global_id (WpProxy * self)
|
||||
{
|
||||
WpProxyPrivate *priv;
|
||||
|
||||
g_return_val_if_fail (WP_IS_PROXY (self), 0);
|
||||
|
||||
priv = wp_proxy_get_instance_private (self);
|
||||
return priv->global_id;
|
||||
}
|
||||
|
||||
gpointer
|
||||
wp_proxy_get_pw_proxy (WpProxy * self)
|
||||
{
|
||||
|
@@ -27,6 +27,7 @@ struct _WpProxyClass
|
||||
void (*destroyed)(WpProxy *wp_proxy);
|
||||
};
|
||||
|
||||
guint wp_proxy_get_global_id (WpProxy * self);
|
||||
gpointer wp_proxy_get_pw_proxy (WpProxy * self);
|
||||
|
||||
G_END_DECLS
|
||||
|
@@ -161,7 +161,7 @@ proxy_port_created(GObject *initable, GAsyncResult *res, gpointer d)
|
||||
return;
|
||||
|
||||
/* Create the proxy node asynchronically */
|
||||
wp_proxy_node_new(proxy, proxy_node_created, pi);
|
||||
wp_proxy_node_new(pi->node_id, proxy, proxy_node_created, pi);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -254,7 +254,7 @@ handle_port(struct module_data *data, uint32_t id, uint32_t parent_id,
|
||||
pi->proxy_port = NULL;
|
||||
|
||||
/* Create the proxy port asynchronically */
|
||||
wp_proxy_port_new(proxy, proxy_port_created, pi);
|
||||
wp_proxy_port_new(id, proxy, proxy_port_created, pi);
|
||||
}
|
||||
|
||||
static void
|
||||
|
@@ -206,25 +206,16 @@ simple_endpoint_prepare_link (WpEndpoint * ep, guint32 stream_id,
|
||||
WpEndpointLink * link, GVariant ** properties, GError ** error)
|
||||
{
|
||||
WpPipewireSimpleEndpoint *self = WP_PIPEWIRE_SIMPLE_ENDPOINT (ep);
|
||||
const struct pw_node_info *node_info = NULL;
|
||||
uint32_t node_id = wp_proxy_get_global_id(WP_PROXY(self->proxy_node));
|
||||
uint32_t port_id = wp_proxy_get_global_id(WP_PROXY(self->proxy_port));
|
||||
GVariantBuilder b;
|
||||
|
||||
/* TODO: Since the linking with a 1 port client works when passing -1 as
|
||||
* a port parameter, there is no need to find the port and set it in the
|
||||
* properties. However, we need to add logic here and select the correct
|
||||
* port in case the client has more than 1 port */
|
||||
|
||||
/* Get the node info */
|
||||
node_info = wp_proxy_node_get_info(self->proxy_node);
|
||||
if (!node_info)
|
||||
return FALSE;
|
||||
|
||||
/* Set the properties */
|
||||
g_variant_builder_init (&b, G_VARIANT_TYPE_VARDICT);
|
||||
g_variant_builder_add (&b, "{sv}", "node-id",
|
||||
g_variant_new_uint32 (node_info->id));
|
||||
g_variant_new_uint32 (node_id));
|
||||
g_variant_builder_add (&b, "{sv}", "node-port-id",
|
||||
g_variant_new_uint32 (-1));
|
||||
g_variant_new_uint32 (port_id));
|
||||
*properties = g_variant_builder_end (&b);
|
||||
|
||||
return TRUE;
|
||||
|
@@ -152,7 +152,7 @@ proxy_port_created(GObject *initable, GAsyncResult *res, gpointer data)
|
||||
return;
|
||||
|
||||
/* Create the proxy node asynchronically */
|
||||
wp_proxy_node_new(proxy, proxy_node_created, pi);
|
||||
wp_proxy_node_new(pi->node_id, proxy, proxy_node_created, pi);
|
||||
}
|
||||
|
||||
static void
|
||||
@@ -215,7 +215,7 @@ handle_port(struct impl *impl, uint32_t id, uint32_t parent_id,
|
||||
pi->proxy_port = NULL;
|
||||
|
||||
/* Create the proxy port asynchronically */
|
||||
wp_proxy_port_new(proxy, proxy_port_created, pi);
|
||||
wp_proxy_port_new(id, proxy, proxy_port_created, pi);
|
||||
}
|
||||
|
||||
static void
|
||||
|
Reference in New Issue
Block a user