stream: get the node id from the info struct when preparing link

This commit is contained in:
Julian Bouzas
2019-10-28 09:29:31 +01:00
committed by George Kiagiadakis
parent b2e1e76460
commit b94cc897ac

View File

@@ -31,6 +31,7 @@ struct _WpAudioStreamPrivate
/* Stream Port Proxies */ /* Stream Port Proxies */
GPtrArray *port_proxies; GPtrArray *port_proxies;
GVariantBuilder port_vb;
/* Stream Controls */ /* Stream Controls */
gfloat volume; gfloat volume;
@@ -478,20 +479,22 @@ wp_audio_stream_get_info (WpAudioStream * self)
static void static void
port_proxies_foreach_func(gpointer data, gpointer user_data) port_proxies_foreach_func(gpointer data, gpointer user_data)
{ {
WpAudioStream *self = user_data;
WpAudioStreamPrivate *priv = wp_audio_stream_get_instance_private (self);
WpProxyPort *port = data; WpProxyPort *port = data;
GVariantBuilder *b = user_data; const struct pw_node_info *node_info;
const struct pw_port_info *info; const struct pw_port_info *port_info;
g_autoptr (WpProperties) props = NULL; g_autoptr (WpProperties) props = NULL;
const gchar *node_id, *channel; const gchar *channel;
uint32_t node_id_n, channel_n = SPA_AUDIO_CHANNEL_UNKNOWN; uint32_t channel_n = SPA_AUDIO_CHANNEL_UNKNOWN;
info = wp_proxy_port_get_info (port); node_info = wp_proxy_node_get_info (priv->proxy);
g_return_if_fail (node_info);
port_info = wp_proxy_port_get_info (port);
g_return_if_fail (port_info);
props = wp_proxy_port_get_properties (port); props = wp_proxy_port_get_properties (port);
node_id = wp_properties_get (props, PW_KEY_NODE_ID);
g_return_if_fail (node_id);
node_id_n = atoi(node_id);
channel = wp_properties_get (props, PW_KEY_AUDIO_CHANNEL); channel = wp_properties_get (props, PW_KEY_AUDIO_CHANNEL);
if (channel) { if (channel) {
const struct spa_type_info *t = spa_type_audio_channel; const struct spa_type_info *t = spa_type_audio_channel;
@@ -510,8 +513,8 @@ port_proxies_foreach_func(gpointer data, gpointer user_data)
uint32 channel; // enum spa_audio_channel uint32 channel; // enum spa_audio_channel
uint8 direction; // enum spa_direction uint8 direction; // enum spa_direction
*/ */
g_variant_builder_add (b, "(uuuy)", node_id_n, info->id, channel_n, g_variant_builder_add (&priv->port_vb, "(uuuy)", node_info->id,
(guint8) info->direction); port_info->id, channel_n, (guint8) port_info->direction);
} }
gboolean gboolean
@@ -519,12 +522,11 @@ wp_audio_stream_prepare_link (WpAudioStream * self, GVariant ** properties,
GError ** error) GError ** error)
{ {
WpAudioStreamPrivate *priv = wp_audio_stream_get_instance_private (self); WpAudioStreamPrivate *priv = wp_audio_stream_get_instance_private (self);
GVariantBuilder b;
/* Create a variant array with all the ports */ /* Create a variant array with all the ports */
g_variant_builder_init (&b, G_VARIANT_TYPE ("a(uuuy)")); g_variant_builder_init (&priv->port_vb, G_VARIANT_TYPE ("a(uuuy)"));
g_ptr_array_foreach(priv->port_proxies, port_proxies_foreach_func, &b); g_ptr_array_foreach(priv->port_proxies, port_proxies_foreach_func, self);
*properties = g_variant_builder_end (&b); *properties = g_variant_builder_end (&priv->port_vb);
return TRUE; return TRUE;
} }