diff --git a/lib/wp/proxy-node.c b/lib/wp/proxy-node.c index 5ca2ce210906dd0daaf189196e13b2ea5ba47707..9b518365d83e96ccaf813f4736db2aeb1b9d9f8f 100644 --- a/lib/wp/proxy-node.c +++ b/lib/wp/proxy-node.c @@ -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); } diff --git a/lib/wp/proxy-node.h b/lib/wp/proxy-node.h index 67db9d572699b69fdc8a958f0df37bedc1b11211..12feba0b79213a95706b32a6fda8e4edab3dae66 100644 --- a/lib/wp/proxy-node.h +++ b/lib/wp/proxy-node.h @@ -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); diff --git a/lib/wp/proxy-port.c b/lib/wp/proxy-port.c index 2c344beb88a90f638cd949a9a84e77e735891e00..07ab144ce4e32d4b90a8436f3c0b43a39b409363 100644 --- a/lib/wp/proxy-port.c +++ b/lib/wp/proxy-port.c @@ -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); } diff --git a/lib/wp/proxy-port.h b/lib/wp/proxy-port.h index c8b9e173d9f7b88e38002a680b1de5b1aaaa94a5..718c8da67e9c91291af79258aed72bd231259033 100644 --- a/lib/wp/proxy-port.h +++ b/lib/wp/proxy-port.h @@ -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); diff --git a/lib/wp/proxy.c b/lib/wp/proxy.c index 042d528454987dd5346f55942a0c500ad8cd70f2..025507ba3e75c46949bd3e79775657d067add790 100644 --- a/lib/wp/proxy.c +++ b/lib/wp/proxy.c @@ -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) { diff --git a/lib/wp/proxy.h b/lib/wp/proxy.h index f3f894836130cd44061139ac7f678af5549f0722..456b29b4c17625b4390b186dd5ad48cc45e12047 100644 --- a/lib/wp/proxy.h +++ b/lib/wp/proxy.h @@ -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 diff --git a/modules/module-pipewire.c b/modules/module-pipewire.c index 52cee54fed2d6aef82f493bcf13c26f389dc6103..69fdf346a9824babdb892e313d87b316c35ea8fc 100644 --- a/modules/module-pipewire.c +++ b/modules/module-pipewire.c @@ -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 diff --git a/modules/module-pipewire/simple-endpoint.c b/modules/module-pipewire/simple-endpoint.c index 6446e681aadab45dbfef6f562f2bb77fa9388b60..6f9aa6937ccf98941396b3a048f926b0b55827e2 100644 --- a/modules/module-pipewire/simple-endpoint.c +++ b/modules/module-pipewire/simple-endpoint.c @@ -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; diff --git a/modules/module-pw-alsa-udev.c b/modules/module-pw-alsa-udev.c index 53ccf2436225dbb684c0845b7e889bfcd80fcdd1..ec15c6bc22efea42489f2b9ac8a940e338e73903 100644 --- a/modules/module-pw-alsa-udev.c +++ b/modules/module-pw-alsa-udev.c @@ -17,7 +17,7 @@ struct impl { - WpCore *core; + WpModule *module; /* Remote */ struct spa_hook remote_listener; @@ -85,6 +85,7 @@ proxy_node_created(GObject *initable, GAsyncResult *res, gpointer data) { struct proxy_info *pi = data; const struct impl *impl = pi->impl; + g_autoptr (WpCore) core = wp_module_get_core (impl->module); g_autoptr(WpProxyNode) proxy_node = NULL; struct endpoint_info *ei = NULL; GVariantBuilder b; @@ -115,7 +116,7 @@ proxy_node_created(GObject *initable, GAsyncResult *res, gpointer data) endpoint_props = g_variant_builder_end (&b); /* Create and register the endpoint */ - endpoint = wp_factory_make (impl->core, "pw-audio-softdsp-endpoint", + endpoint = wp_factory_make (core, "pw-audio-softdsp-endpoint", WP_TYPE_ENDPOINT, endpoint_props); /* Register the endpoint */ @@ -152,7 +153,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 +216,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 @@ -272,7 +273,7 @@ module_destroy (gpointer data) } struct impl * -module_create (WpCore * core) +module_create (WpModule * module, WpCore * core) { struct impl *impl; WpRemote *remote; @@ -281,7 +282,7 @@ module_create (WpCore * core) impl = g_new0(struct impl, 1); /* Set core */ - impl->core = core; + impl->module = module; /* Set remote */ remote = wp_core_get_global(core, WP_GLOBAL_REMOTE_PIPEWIRE); @@ -300,7 +301,7 @@ void wireplumber__module_init (WpModule * module, WpCore * core, GVariant * args) { /* Create the impl */ - struct impl *impl = module_create (core); + struct impl *impl = module_create (module, core); /* Set destroy callback for impl */ wp_module_set_destroy_callback (module, module_destroy, impl);