mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-10-29 05:40:27 -04:00
port: show peers on D-Bus
This commit is contained in:
parent
888353bb9d
commit
b85420ddb4
3 changed files with 57 additions and 0 deletions
|
|
@ -69,6 +69,7 @@ struct _PinosPortPrivate
|
|||
|
||||
PinosBuffer *buffer;
|
||||
PinosPort *peers[16];
|
||||
gchar **peer_paths;
|
||||
gint n_peers;
|
||||
|
||||
PinosReceivedBufferCallback received_buffer_cb;
|
||||
|
|
@ -86,6 +87,7 @@ enum
|
|||
PROP_MAIN_CONTEXT,
|
||||
PROP_NAME,
|
||||
PROP_DIRECTION,
|
||||
PROP_PEERS,
|
||||
PROP_POSSIBLE_FORMATS,
|
||||
PROP_FORMAT,
|
||||
PROP_PROPERTIES,
|
||||
|
|
@ -579,6 +581,29 @@ buffer_queued:
|
|||
}
|
||||
}
|
||||
|
||||
static void
|
||||
update_peer_paths (PinosPort *port)
|
||||
{
|
||||
gchar **paths;
|
||||
gint i;
|
||||
gint path_index = 0;
|
||||
|
||||
paths = g_malloc0 (sizeof (port->priv->peers) + 1);
|
||||
for (i = 0; i < port->priv->n_peers; i++) {
|
||||
PinosPort *peer;
|
||||
gchar *path;
|
||||
|
||||
peer = port->priv->peers[i];
|
||||
if (peer == NULL)
|
||||
continue;
|
||||
g_object_get (peer, "object-path", &path, NULL);
|
||||
paths[path_index++] = path;
|
||||
}
|
||||
|
||||
g_object_set (port, "peers", paths, NULL);
|
||||
g_strfreev (paths);
|
||||
}
|
||||
|
||||
/**
|
||||
* pinos_port_link:
|
||||
* @source: a source #PinosPort
|
||||
|
|
@ -605,6 +630,9 @@ pinos_port_link (PinosPort *source, PinosPort *destination)
|
|||
source->priv->peers[source->priv->n_peers++] = destination;
|
||||
destination->priv->peers[destination->priv->n_peers++] = source;
|
||||
|
||||
update_peer_paths (source);
|
||||
update_peer_paths (destination);
|
||||
|
||||
if (source->priv->format) {
|
||||
PinosBufferBuilder builder;
|
||||
PinosBuffer pbuf;
|
||||
|
|
@ -658,6 +686,9 @@ pinos_port_unlink (PinosPort *source, PinosPort *destination)
|
|||
destination->priv->peers[i] = NULL;
|
||||
}
|
||||
|
||||
update_peer_paths (source);
|
||||
update_peer_paths (destination);
|
||||
|
||||
g_debug ("port %p: unlinked from %p", source, destination);
|
||||
g_signal_emit (source, signals[SIGNAL_UNLINKED], 0, destination);
|
||||
g_signal_emit (destination, signals[SIGNAL_UNLINKED], 0, source);
|
||||
|
|
@ -941,6 +972,10 @@ pinos_port_get_property (GObject *_object,
|
|||
g_value_set_string (value, priv->name);
|
||||
break;
|
||||
|
||||
case PROP_PEERS:
|
||||
g_value_set_boxed (value, priv->peer_paths);
|
||||
break;
|
||||
|
||||
case PROP_DIRECTION:
|
||||
g_value_set_enum (value, priv->direction);
|
||||
break;
|
||||
|
|
@ -989,6 +1024,12 @@ pinos_port_set_property (GObject *_object,
|
|||
priv->direction = g_value_get_enum (value);
|
||||
break;
|
||||
|
||||
case PROP_PEERS:
|
||||
if (priv->peer_paths)
|
||||
g_strfreev (priv->peer_paths);
|
||||
priv->peer_paths = g_value_dup_boxed (value);
|
||||
break;
|
||||
|
||||
case PROP_POSSIBLE_FORMATS:
|
||||
if (priv->possible_formats)
|
||||
g_bytes_unref (priv->possible_formats);
|
||||
|
|
@ -1117,6 +1158,15 @@ pinos_port_class_init (PinosPortClass * klass)
|
|||
G_PARAM_CONSTRUCT_ONLY |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_PEERS,
|
||||
g_param_spec_boxed ("peers",
|
||||
"Peers",
|
||||
"The peer ports of the port",
|
||||
G_TYPE_STRV,
|
||||
G_PARAM_READWRITE |
|
||||
G_PARAM_STATIC_STRINGS));
|
||||
|
||||
g_object_class_install_property (gobject_class,
|
||||
PROP_POSSIBLE_FORMATS,
|
||||
g_param_spec_boxed ("possible-formats",
|
||||
|
|
|
|||
|
|
@ -109,6 +109,8 @@
|
|||
1 = an output port
|
||||
-->
|
||||
<property name='Direction' type='u' access='read' />
|
||||
<!-- Peers: peer ports of this port -->
|
||||
<property name='Peers' type='ao' access='read' />
|
||||
<!-- Properties: extra port properties -->
|
||||
<property name='Properties' type='a{sv}' access='read' />
|
||||
<!-- PossibleFormats:
|
||||
|
|
|
|||
|
|
@ -186,6 +186,11 @@ on_property_notify (GObject *obj,
|
|||
GBytes *bytes = pinos_port_get_format (port);
|
||||
pinos_port1_set_format (priv->iface, bytes ? g_bytes_get_data (bytes, NULL) : NULL);
|
||||
}
|
||||
if (pspec == NULL || strcmp (g_param_spec_get_name (pspec), "peers") == 0) {
|
||||
const gchar *const *paths;
|
||||
g_object_get (port, "peers", &paths, NULL);
|
||||
pinos_port1_set_peers (priv->iface, paths);
|
||||
}
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue