From 6fcd0985a3898b5f18a3a547c9b0dd9ef6c96cf6 Mon Sep 17 00:00:00 2001 From: David Svensson Fors Date: Mon, 13 Jun 2016 09:45:30 +0200 Subject: [PATCH] pinos-monitor: show peer ports --- pinos/client/introspect.c | 22 +++++++++++++++++++--- pinos/client/introspect.h | 2 ++ pinos/tools/pinos-monitor.c | 33 ++++++++++++++++++++++++++++++--- 3 files changed, 51 insertions(+), 6 deletions(-) diff --git a/pinos/client/introspect.c b/pinos/client/introspect.c index 06df2f0e6..ea6bb480f 100644 --- a/pinos/client/introspect.c +++ b/pinos/client/introspect.c @@ -103,6 +103,19 @@ G_STMT_START { } \ } G_STMT_END +#define SET_OBJV(name, field, idx) \ +G_STMT_START { \ + GVariant *variant; \ + if (!changed || g_hash_table_contains (changed, name)) \ + info->change_mask |= 1 << idx; \ + if ((variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), name))) { \ + info->field = g_variant_dup_objv (variant, NULL); \ + g_variant_unref (variant); \ + } else { \ + info->field = NULL; \ + } \ +} G_STMT_END + static void daemon_fill_info (PinosDaemonInfo *info, GDBusProxy *proxy) { @@ -324,9 +337,10 @@ port_fill_info (PinosPortInfo *info, GDBusProxy *proxy) info->change_mask = 0; SET_STRING ("Name", name, 0); - SET_PROPERTIES ("Properties", properties, 1); - SET_BYTES ("PossibleFormats", possible_formats, 2); - SET_BYTES ("Format", format, 3); + SET_OBJV ("Peers", peers, 1); + SET_PROPERTIES ("Properties", properties, 2); + SET_BYTES ("PossibleFormats", possible_formats, 3); + SET_BYTES ("Format", format, 4); if (changed) g_hash_table_remove_all (changed); @@ -335,6 +349,8 @@ port_fill_info (PinosPortInfo *info, GDBusProxy *proxy) static void port_clear_info (PinosPortInfo *info) { + if (info->peers) + g_strfreev (info->peers); if (info->properties) pinos_properties_free (info->properties); if (info->possible_formats) diff --git a/pinos/client/introspect.h b/pinos/client/introspect.h index 0a32cf02b..43a2cf472 100644 --- a/pinos/client/introspect.h +++ b/pinos/client/introspect.h @@ -212,6 +212,7 @@ void pinos_context_get_node_info_by_id (PinosContext *context, * @direction: the direction of the port * @change_mask: bitfield of changed fields since last call * @name: name the port, suitable for display + * @peers: paths to peer ports * @properties: the properties of the port * @possible_formats: the possible formats this port can consume * @format: the current format on this port @@ -227,6 +228,7 @@ typedef struct { guint64 change_mask; const char *name; PinosProperties *properties; + gchar **peers; GBytes *possible_formats; GBytes *format; } PinosPortInfo; diff --git a/pinos/tools/pinos-monitor.c b/pinos/tools/pinos-monitor.c index 7f3f3980f..404bb6991 100644 --- a/pinos/tools/pinos-monitor.c +++ b/pinos/tools/pinos-monitor.c @@ -92,6 +92,32 @@ print_properties (PinosProperties *props, gchar mark) } } +static void +print_peers (gchar **peers, gchar mark) +{ + GValue list = G_VALUE_INIT; + gint idx = 0; + gchar *str; + + g_value_init (&list, GST_TYPE_LIST); + + if (peers != NULL) { + while (peers[idx]) { + GValue peer = G_VALUE_INIT; + + g_value_init (&peer, G_TYPE_STRING); + g_value_set_string (&peer, peers[idx]); + gst_value_list_append_and_take_value (&list, &peer); + idx++; + } + } + + str = gst_value_serialize (&list); + g_print ("%c\tpeers: %s\n", mark, str); + g_free (str); + g_value_unset (&list); +} + static void info_ready (GObject *o, GAsyncResult *res, gpointer user_data) { @@ -153,9 +179,10 @@ dump_port_info (PinosContext *c, const PinosPortInfo *info, gpointer user_data) g_print ("\tnode-path: \"%s\"\n", info->node_path); g_print ("\tdirection: \"%s\"\n", pinos_direction_as_string (info->direction)); g_print ("%c\tname: \"%s\"\n", MARK_CHANGE (0), info->name); - print_properties (info->properties, MARK_CHANGE (1)); - print_formats ("possible formats", info->possible_formats, MARK_CHANGE (2)); - print_formats ("format", info->format, MARK_CHANGE (3)); + print_peers (info->peers, MARK_CHANGE (1)); + print_properties (info->properties, MARK_CHANGE (2)); + print_formats ("possible formats", info->possible_formats, MARK_CHANGE (3)); + print_formats ("format", info->format, MARK_CHANGE (4)); } }