From 0ad0c9fb9d9f6e81da21ad3c20e974e8a3507953 Mon Sep 17 00:00:00 2001 From: Julian Bouzas Date: Wed, 11 Dec 2019 16:13:42 -0500 Subject: [PATCH] base-endpoint: add _get_priority API --- lib/wp/base-endpoint.c | 27 +++++++++++++++++++ lib/wp/base-endpoint.h | 1 + modules/module-config-endpoint/context.c | 2 ++ .../module-pipewire/audio-softdsp-endpoint.c | 5 +++- .../config-endpoint/endpoint-audiotestsrc.c | 5 +++- tests/modules/config-policy/endpoint-fake.c | 1 + 6 files changed, 39 insertions(+), 2 deletions(-) diff --git a/lib/wp/base-endpoint.c b/lib/wp/base-endpoint.c index 5508f22d..33f518cc 100644 --- a/lib/wp/base-endpoint.c +++ b/lib/wp/base-endpoint.c @@ -96,6 +96,7 @@ struct _WpBaseEndpointPrivate gchar media_class[40]; guint direction; guint64 creation_time; + guint priority; GPtrArray *streams; GPtrArray *controls; GPtrArray *links; @@ -109,6 +110,7 @@ enum { PROP_MEDIA_CLASS, PROP_DIRECTION, PROP_CREATION_TIME, + PROP_PRIORITY, }; enum { @@ -223,6 +225,9 @@ wp_base_endpoint_set_property (GObject * object, guint property_id, case PROP_CREATION_TIME: priv->creation_time = g_value_get_uint64(value); break; + case PROP_PRIORITY: + priv->priority = g_value_get_uint(value); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -252,6 +257,9 @@ wp_base_endpoint_get_property (GObject * object, guint property_id, GValue * val case PROP_CREATION_TIME: g_value_set_uint64 (value, priv->creation_time); break; + case PROP_PRIORITY: + g_value_set_uint (value, priv->priority); + break; default: G_OBJECT_WARN_INVALID_PROPERTY_ID (object, property_id, pspec); break; @@ -318,6 +326,14 @@ wp_base_endpoint_class_init (WpBaseEndpointClass * klass) "The time that this endpoint was created, in monotonic time", 0, G_MAXUINT64, 0, G_PARAM_READABLE | G_PARAM_STATIC_STRINGS)); + /** + * WpBaseEndpoint::direction: + * The priority of the endpoint: + */ + g_object_class_install_property (object_class, PROP_PRIORITY, + g_param_spec_uint ("priority", "priority", + "The priority of the endpoint", 0, G_MAXUINT, 0, + G_PARAM_READWRITE | G_PARAM_CONSTRUCT_ONLY | G_PARAM_STATIC_STRINGS)); } /** @@ -451,6 +467,17 @@ wp_base_endpoint_get_creation_time (WpBaseEndpoint * self) return priv->creation_time; } +guint32 +wp_base_endpoint_get_priority (WpBaseEndpoint * self) +{ + WpBaseEndpointPrivate *priv; + + g_return_val_if_fail (WP_IS_BASE_ENDPOINT (self), -1); + + priv = wp_base_endpoint_get_instance_private (self); + return priv->priority; +} + WpProperties * wp_base_endpoint_get_properties (WpBaseEndpoint * self) { diff --git a/lib/wp/base-endpoint.h b/lib/wp/base-endpoint.h index 7e485cb6..28aaf849 100644 --- a/lib/wp/base-endpoint.h +++ b/lib/wp/base-endpoint.h @@ -54,6 +54,7 @@ const gchar * wp_base_endpoint_get_name (WpBaseEndpoint * self); const gchar * wp_base_endpoint_get_media_class (WpBaseEndpoint * self); guint wp_base_endpoint_get_direction (WpBaseEndpoint * self); guint64 wp_base_endpoint_get_creation_time (WpBaseEndpoint * self); +guint32 wp_base_endpoint_get_priority (WpBaseEndpoint * self); WpProperties * wp_base_endpoint_get_properties (WpBaseEndpoint * self); const char * wp_base_endpoint_get_role (WpBaseEndpoint * self); diff --git a/modules/module-config-endpoint/context.c b/modules/module-config-endpoint/context.c index 202eaa5a..ce0cbc64 100644 --- a/modules/module-config-endpoint/context.c +++ b/modules/module-config-endpoint/context.c @@ -141,6 +141,8 @@ on_node_added (WpObjectManager *om, WpProxy *proxy, gpointer d) "media-class", g_variant_new_string (media_class)); g_variant_builder_add (&b, "{sv}", "direction", g_variant_new_uint32 (endpoint_data->e.direction)); + g_variant_builder_add (&b, "{sv}", + "priority", g_variant_new_uint32 (endpoint_data->e.priority)); g_variant_builder_add (&b, "{sv}", "proxy-node", g_variant_new_uint64 ((guint64) proxy)); if (streams_variant) diff --git a/modules/module-pipewire/audio-softdsp-endpoint.c b/modules/module-pipewire/audio-softdsp-endpoint.c index 2a0e3d1e..4ee9acd5 100644 --- a/modules/module-pipewire/audio-softdsp-endpoint.c +++ b/modules/module-pipewire/audio-softdsp-endpoint.c @@ -495,7 +495,7 @@ audio_softdsp_endpoint_factory (WpFactory * factory, GType type, GVariant * prop { g_autoptr (WpCore) core = NULL; const gchar *name, *media_class; - guint direction; + guint direction, priority; guint64 node; g_autoptr (GVariant) streams = NULL; @@ -513,6 +513,8 @@ audio_softdsp_endpoint_factory (WpFactory * factory, GType type, GVariant * prop return; if (!g_variant_lookup (properties, "direction", "u", &direction)) return; + if (!g_variant_lookup (properties, "priority", "u", &priority)) + return; if (!g_variant_lookup (properties, "proxy-node", "t", &node)) return; streams = g_variant_lookup_value (properties, "streams", @@ -525,6 +527,7 @@ audio_softdsp_endpoint_factory (WpFactory * factory, GType type, GVariant * prop "name", name, "media-class", media_class, "direction", direction, + "priority", priority, "proxy-node", (gpointer) node, "streams", streams, NULL); diff --git a/tests/modules/config-endpoint/endpoint-audiotestsrc.c b/tests/modules/config-endpoint/endpoint-audiotestsrc.c index 5b950892..ecc14331 100644 --- a/tests/modules/config-endpoint/endpoint-audiotestsrc.c +++ b/tests/modules/config-endpoint/endpoint-audiotestsrc.c @@ -209,7 +209,7 @@ wp_endpoint_audiotestsrc_factory (WpFactory * factory, GType type, { g_autoptr (WpCore) core = NULL; const gchar *name, *media_class; - guint direction; + guint direction, priority; guint64 node; g_autoptr (GVariant) streams = NULL; @@ -222,6 +222,8 @@ wp_endpoint_audiotestsrc_factory (WpFactory * factory, GType type, return; if (!g_variant_lookup (properties, "direction", "u", &direction)) return; + if (!g_variant_lookup (properties, "priority", "u", &priority)) + return; if (!g_variant_lookup (properties, "proxy-node", "t", &node)) return; streams = g_variant_lookup_value (properties, "streams", @@ -233,6 +235,7 @@ wp_endpoint_audiotestsrc_factory (WpFactory * factory, GType type, "name", name, "media-class", media_class, "direction", direction, + "priority", priority, "proxy-node", (gpointer) node, "streams", streams, NULL); diff --git a/tests/modules/config-policy/endpoint-fake.c b/tests/modules/config-policy/endpoint-fake.c index 75926cbb..a3a42449 100644 --- a/tests/modules/config-policy/endpoint-fake.c +++ b/tests/modules/config-policy/endpoint-fake.c @@ -224,6 +224,7 @@ wp_fake_endpoint_new_async (WpCore *core, const char *name, "name", name, "media-class", media_class, "direction", direction, + "priority", 0, "properties", props, "role", role, "streams", streams,