mirror of
https://gitlab.freedesktop.org/pipewire/pipewire.git
synced 2025-11-19 07:00:10 -05:00
introspect: improve instrospection
Pass changed properties around so that we can print them
This commit is contained in:
parent
51f18b540a
commit
8361f74646
8 changed files with 110 additions and 59 deletions
|
|
@ -35,6 +35,7 @@ static void subscription_cb (PinosSubscribe *subscribe,
|
|||
PinosSubscriptionEvent event,
|
||||
PinosSubscriptionFlags flags,
|
||||
GDBusProxy *object,
|
||||
GStrv properties,
|
||||
gpointer user_data);
|
||||
|
||||
enum
|
||||
|
|
@ -246,6 +247,8 @@ pinos_context_class_init (PinosContextClass * klass)
|
|||
* @event: A #PinosSubscriptionEvent
|
||||
* @flags: #PinosSubscriptionFlags indicating the object
|
||||
* @object: the GDBusProxy object
|
||||
* @properties: extra properties that changed or %NULL when all properties
|
||||
* are affected (new and remove)
|
||||
*
|
||||
* Notify about a new object that was added/removed/modified.
|
||||
*/
|
||||
|
|
@ -257,10 +260,11 @@ pinos_context_class_init (PinosContextClass * klass)
|
|||
NULL,
|
||||
g_cclosure_marshal_generic,
|
||||
G_TYPE_NONE,
|
||||
3,
|
||||
4,
|
||||
PINOS_TYPE_SUBSCRIPTION_EVENT,
|
||||
PINOS_TYPE_SUBSCRIPTION_FLAGS,
|
||||
G_TYPE_DBUS_PROXY);
|
||||
G_TYPE_DBUS_PROXY,
|
||||
G_TYPE_STRV);
|
||||
|
||||
}
|
||||
|
||||
|
|
@ -411,17 +415,18 @@ subscription_cb (PinosSubscribe *subscribe,
|
|||
PinosSubscriptionEvent event,
|
||||
PinosSubscriptionFlags flags,
|
||||
GDBusProxy *object,
|
||||
GStrv properties,
|
||||
gpointer user_data)
|
||||
{
|
||||
PinosContext *context = user_data;
|
||||
PinosContextPrivate *priv = context->priv;
|
||||
|
||||
switch (flags) {
|
||||
case PINOS_SUBSCRIPTION_FLAGS_DAEMON:
|
||||
case PINOS_SUBSCRIPTION_FLAG_DAEMON:
|
||||
priv->daemon = g_object_ref (object);
|
||||
break;
|
||||
|
||||
case PINOS_SUBSCRIPTION_FLAGS_CLIENT:
|
||||
case PINOS_SUBSCRIPTION_FLAG_CLIENT:
|
||||
if (event == PINOS_SUBSCRIPTION_EVENT_NEW) {
|
||||
priv->clients = g_list_prepend (priv->clients, object);
|
||||
} else if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE) {
|
||||
|
|
@ -434,14 +439,14 @@ subscription_cb (PinosSubscribe *subscribe,
|
|||
}
|
||||
break;
|
||||
|
||||
case PINOS_SUBSCRIPTION_FLAGS_SOURCE:
|
||||
case PINOS_SUBSCRIPTION_FLAG_SOURCE:
|
||||
if (event == PINOS_SUBSCRIPTION_EVENT_NEW)
|
||||
priv->sources = g_list_prepend (priv->sources, object);
|
||||
else if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE)
|
||||
priv->sources = g_list_remove (priv->sources, object);
|
||||
break;
|
||||
|
||||
case PINOS_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT:
|
||||
case PINOS_SUBSCRIPTION_FLAG_SOURCE_OUTPUT:
|
||||
if (event == PINOS_SUBSCRIPTION_EVENT_NEW)
|
||||
priv->source_outputs = g_list_prepend (priv->source_outputs, object);
|
||||
else if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE)
|
||||
|
|
@ -455,7 +460,8 @@ subscription_cb (PinosSubscribe *subscribe,
|
|||
0,
|
||||
event,
|
||||
flags,
|
||||
object);
|
||||
object,
|
||||
properties);
|
||||
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -227,10 +227,10 @@ source_fill_info (PinosSourceInfo *info, GDBusProxy *proxy)
|
|||
if ((variant = g_dbus_proxy_get_cached_property (G_DBUS_PROXY (proxy), "PossibleFormats"))) {
|
||||
gsize len;
|
||||
gchar *formats = g_variant_dup_string (variant, &len);
|
||||
info->formats = g_bytes_new_take (formats, len + 1);
|
||||
info->possible_formats = g_bytes_new_take (formats, len + 1);
|
||||
g_variant_unref (variant);
|
||||
} else {
|
||||
info->formats = NULL;
|
||||
info->possible_formats = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -239,8 +239,8 @@ source_clear_info (PinosSourceInfo *info)
|
|||
{
|
||||
if (info->properties)
|
||||
pinos_properties_free (info->properties);
|
||||
if (info->formats)
|
||||
g_bytes_unref (info->formats);
|
||||
if (info->possible_formats)
|
||||
g_bytes_unref (info->possible_formats);
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -124,7 +124,7 @@ typedef enum {
|
|||
* @name: name the source, suitable for display
|
||||
* @properties: the properties of the source
|
||||
* @state: the current state of the source
|
||||
* @formats: the supported formats
|
||||
* @possible formats: the possible formats this source can produce
|
||||
*
|
||||
* The source information. Extra information can be added in later
|
||||
* versions.
|
||||
|
|
@ -135,7 +135,7 @@ typedef struct {
|
|||
const char *name;
|
||||
PinosProperties *properties;
|
||||
PinosSourceState state;
|
||||
GBytes *formats;
|
||||
GBytes *possible_formats;
|
||||
} PinosSourceInfo;
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -179,13 +179,14 @@ subscription_cb (PinosSubscribe *subscribe,
|
|||
PinosSubscriptionEvent event,
|
||||
PinosSubscriptionFlags flags,
|
||||
GDBusProxy *object,
|
||||
GStrv properties,
|
||||
gpointer user_data)
|
||||
{
|
||||
PinosStream *stream = PINOS_STREAM (user_data);
|
||||
PinosStreamPrivate *priv = stream->priv;
|
||||
|
||||
switch (flags) {
|
||||
case PINOS_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT:
|
||||
case PINOS_SUBSCRIPTION_FLAG_SOURCE_OUTPUT:
|
||||
if (event == PINOS_SUBSCRIPTION_EVENT_REMOVE) {
|
||||
if (object == priv->source_output) {
|
||||
priv->error = g_error_new_literal (G_IO_ERROR, G_IO_ERROR_CLOSED, "output disappeared");
|
||||
|
|
|
|||
|
|
@ -92,26 +92,27 @@ subscription_set_state (PinosSubscribe *subscribe,
|
|||
static void
|
||||
notify_event (PinosSubscribe *subscribe,
|
||||
PinosObjectData *data,
|
||||
PinosSubscriptionEvent event)
|
||||
PinosSubscriptionEvent event,
|
||||
GStrv properties)
|
||||
{
|
||||
const gchar *interface_name;
|
||||
PinosSubscriptionFlags flags = 0;
|
||||
|
||||
interface_name = g_dbus_proxy_get_interface_name (data->proxy);
|
||||
if (g_strcmp0 (interface_name, "org.pinos.Daemon1") == 0) {
|
||||
flags = PINOS_SUBSCRIPTION_FLAGS_DAEMON;
|
||||
flags = PINOS_SUBSCRIPTION_FLAG_DAEMON;
|
||||
}
|
||||
else if (g_strcmp0 (interface_name, "org.pinos.Client1") == 0) {
|
||||
flags = PINOS_SUBSCRIPTION_FLAGS_CLIENT;
|
||||
flags = PINOS_SUBSCRIPTION_FLAG_CLIENT;
|
||||
}
|
||||
else if (g_strcmp0 (interface_name, "org.pinos.Source1") == 0) {
|
||||
flags = PINOS_SUBSCRIPTION_FLAGS_SOURCE;
|
||||
flags = PINOS_SUBSCRIPTION_FLAG_SOURCE;
|
||||
}
|
||||
else if (g_strcmp0 (interface_name, "org.pinos.SourceOutput1") == 0) {
|
||||
flags = PINOS_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT;
|
||||
flags = PINOS_SUBSCRIPTION_FLAG_SOURCE_OUTPUT;
|
||||
}
|
||||
g_signal_emit (subscribe, signals[SIGNAL_SUBSCRIPTION_EVENT], 0,
|
||||
event, flags, data->proxy);
|
||||
event, flags, data->proxy, properties);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -121,8 +122,22 @@ on_proxy_properties_changed (GDBusProxy *proxy,
|
|||
gpointer user_data)
|
||||
{
|
||||
PinosObjectData *data = user_data;
|
||||
GPtrArray *ptr;
|
||||
GVariantIter iter;
|
||||
GVariant *value;
|
||||
gchar *key;
|
||||
|
||||
notify_event (data->subscribe, data, PINOS_SUBSCRIPTION_EVENT_CHANGE);
|
||||
ptr = g_ptr_array_new_with_free_func (g_free);
|
||||
g_variant_iter_init (&iter, changed_properties);
|
||||
while (g_variant_iter_loop (&iter, "{sv}", &key, &value)) {
|
||||
g_ptr_array_add (ptr, g_strdup (key));
|
||||
}
|
||||
g_ptr_array_add (ptr, NULL);
|
||||
|
||||
notify_event (data->subscribe, data, PINOS_SUBSCRIPTION_EVENT_CHANGE,
|
||||
(gchar **) ptr->pdata);
|
||||
|
||||
g_ptr_array_free (ptr, TRUE);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
@ -143,7 +158,7 @@ remove_data (PinosSubscribe *subscribe,
|
|||
if (data->pending) {
|
||||
data->removed = TRUE;
|
||||
} else {
|
||||
notify_event (subscribe, data, PINOS_SUBSCRIPTION_EVENT_REMOVE);
|
||||
notify_event (subscribe, data, PINOS_SUBSCRIPTION_EVENT_REMOVE, NULL);
|
||||
object_data_free (data);
|
||||
}
|
||||
}
|
||||
|
|
@ -189,7 +204,7 @@ on_proxy_created (GObject *source_object,
|
|||
(GCallback) on_proxy_properties_changed,
|
||||
data);
|
||||
|
||||
notify_event (subscribe, data, PINOS_SUBSCRIPTION_EVENT_NEW);
|
||||
notify_event (subscribe, data, PINOS_SUBSCRIPTION_EVENT_NEW, NULL);
|
||||
|
||||
for (walk = data->tasks; walk; walk = g_list_next (walk)) {
|
||||
GTask *task = walk->data;
|
||||
|
|
@ -636,6 +651,8 @@ pinos_subscribe_class_init (PinosSubscribeClass * klass)
|
|||
* @event: A #PinosSubscriptionEvent
|
||||
* @flags: #PinosSubscriptionFlags indicating the object
|
||||
* @id: the unique and opaque object id
|
||||
* @properties: extra properties that changed or %NULL when all properties
|
||||
* are affected (new or remove)
|
||||
*
|
||||
* Notify about a new object that was added/removed/modified.
|
||||
*/
|
||||
|
|
@ -647,10 +664,11 @@ pinos_subscribe_class_init (PinosSubscribeClass * klass)
|
|||
NULL,
|
||||
g_cclosure_marshal_generic,
|
||||
G_TYPE_NONE,
|
||||
3,
|
||||
4,
|
||||
PINOS_TYPE_SUBSCRIPTION_EVENT,
|
||||
PINOS_TYPE_SUBSCRIPTION_FLAGS,
|
||||
G_TYPE_POINTER);
|
||||
G_TYPE_POINTER,
|
||||
G_TYPE_STRV);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -45,10 +45,10 @@ typedef enum {
|
|||
} PinosSubscriptionState;
|
||||
|
||||
typedef enum {
|
||||
PINOS_SUBSCRIPTION_FLAGS_DAEMON = (1 << 0),
|
||||
PINOS_SUBSCRIPTION_FLAGS_CLIENT = (1 << 1),
|
||||
PINOS_SUBSCRIPTION_FLAGS_SOURCE = (1 << 2),
|
||||
PINOS_SUBSCRIPTION_FLAGS_SOURCE_OUTPUT = (1 << 3),
|
||||
PINOS_SUBSCRIPTION_FLAG_DAEMON = (1 << 0),
|
||||
PINOS_SUBSCRIPTION_FLAG_CLIENT = (1 << 1),
|
||||
PINOS_SUBSCRIPTION_FLAG_SOURCE = (1 << 2),
|
||||
PINOS_SUBSCRIPTION_FLAG_SOURCE_OUTPUT = (1 << 3),
|
||||
} PinosSubscriptionFlags;
|
||||
|
||||
#define PINOS_SUBSCRIPTION_FLAGS_ALL 0xf
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue