From 1bae4a6a4191523c73fb5d8cc87960ebc06e3d0c Mon Sep 17 00:00:00 2001 From: George Kiagiadakis Date: Wed, 3 Jun 2020 20:28:43 +0300 Subject: [PATCH] proxy: use a core sync to know when Props have been enumerated This is necessary to finish augmenting nodes that advertise PropInfo & Props in their param info but they don't actually have any properties, so there is no param event emitted (ex. the jack device nodes) Because the sync is synchronous with the calls over the protocol, the callback is ensured to be called after all the param events have been emitted --- lib/wp/proxy.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) diff --git a/lib/wp/proxy.c b/lib/wp/proxy.c index 7876018c..46693c10 100644 --- a/lib/wp/proxy.c +++ b/lib/wp/proxy.c @@ -284,6 +284,18 @@ wp_proxy_get_gobj_property (GObject * object, guint property_id, GValue * value, } } +static void +wp_proxy_enum_props_done (WpCore * core, GAsyncResult * res, WpProxy * self) +{ + g_autoptr (GError) error = NULL; + if (!wp_core_sync_finish (core, res, &error)) { + wp_warning_object (self, "core sync failed: %s", error->message); + } + + wp_trace_object (self, "enum props done"); + wp_proxy_set_feature_ready (self, WP_PROXY_FEATURE_PROPS); +} + static void wp_proxy_enable_feature_props (WpProxy * self) { @@ -303,6 +315,8 @@ wp_proxy_enable_feature_props (WpProxy * self) } if (have_propinfo && have_props) { + g_autoptr (WpCore) core = wp_proxy_get_core (self); + if (!klass->enum_params || !klass->subscribe_params) { wp_proxy_augment_error (self, g_error_new (WP_DOMAIN_LIBRARY, WP_LIBRARY_ERROR_INVARIANT, @@ -312,6 +326,8 @@ wp_proxy_enable_feature_props (WpProxy * self) klass->enum_params (self, SPA_PARAM_PropInfo, 0, -1, NULL); klass->subscribe_params (self, ids, SPA_N_ELEMENTS (ids)); + wp_core_sync (core, NULL, (GAsyncReadyCallback) wp_proxy_enum_props_done, + self); } else { /* declare as ready with no props */ wp_proxy_set_feature_ready (self, WP_PROXY_FEATURE_PROPS); @@ -1085,10 +1101,6 @@ wp_proxy_handle_event_param (void * proxy, int seq, uint32_t id, wp_trace_boxed (WP_TYPE_SPA_POD, w_param, "storing Props on " WP_OBJECT_FORMAT, WP_OBJECT_ARGS (self)); wp_props_store (priv->props, NULL, g_steal_pointer (&w_param)); - - /* we receive PropInfo before Props; once we get Props, we know we have - completed caching of props, so the feature is ready */ - wp_proxy_set_feature_ready (self, WP_PROXY_FEATURE_PROPS); break; default: break;