From e1e6411e19922e42946a15cf46ec18f22129a40c Mon Sep 17 00:00:00 2001 From: George Kiagiadakis <george.kiagiadakis@collabora.com> Date: Tue, 2 Jun 2020 19:09:18 +0300 Subject: [PATCH] proxy: when requesting Props, only try to enum them if the proxy supports them otherwise we get stuck waiting for the param event and we get warnings on the debug log --- lib/wp/proxy.c | 55 +++++++++++++++++++++++++++++++++++++++----------- 1 file changed, 43 insertions(+), 12 deletions(-) diff --git a/lib/wp/proxy.c b/lib/wp/proxy.c index 835ca37e..a0dc9caf 100644 --- a/lib/wp/proxy.c +++ b/lib/wp/proxy.c @@ -284,6 +284,43 @@ wp_proxy_get_gobj_property (GObject * object, guint property_id, GValue * value, } } +static void +wp_proxy_enable_feature_props (WpProxy * self) +{ + WpProxyClass *klass = WP_PROXY_GET_CLASS (self); + struct spa_param_info *param_info; + guint n_params; + guint have_propinfo = FALSE, have_props = FALSE; + uint32_t ids[] = { SPA_PARAM_Props }; + + /* check if we actually have props */ + param_info = klass->get_param_info (self, &n_params); + for (guint i = 0; i < n_params; i++) { + if (param_info[i].id == SPA_PARAM_PropInfo) + have_propinfo = TRUE; + else if (param_info[i].id == SPA_PARAM_Props) + have_props = TRUE; + } + + if (have_propinfo && have_props) { + if (!klass->enum_params || !klass->subscribe_params) { + wp_proxy_augment_error (self, g_error_new (WP_DOMAIN_LIBRARY, + WP_LIBRARY_ERROR_INVARIANT, + "Proxy does not support enum/subscribe params API")); + return; + } + + klass->enum_params (self, SPA_PARAM_PropInfo, 0, -1, NULL); + klass->subscribe_params (self, ids, SPA_N_ELEMENTS (ids)); + } else { + /* declare as ready with no props */ + wp_proxy_set_feature_ready (self, WP_PROXY_FEATURE_PROPS); + } + + g_signal_handlers_disconnect_by_func (self, + wp_proxy_enable_feature_props, self); +} + static void wp_proxy_default_augment (WpProxy * self, WpProxyFeatures features) { @@ -310,19 +347,13 @@ wp_proxy_default_augment (WpProxy * self, WpProxyFeatures features) } if (features & WP_PROXY_FEATURE_PROPS && !priv->props) { - WpProxyClass *klass = WP_PROXY_GET_CLASS (self); - uint32_t ids[] = { SPA_PARAM_Props }; - - if (!klass->enum_params || !klass->subscribe_params) { - wp_proxy_augment_error (self, g_error_new (WP_DOMAIN_LIBRARY, - WP_LIBRARY_ERROR_OPERATION_FAILED, - "Proxy does not support enum/subscribe params API")); - return; - } - wp_proxy_set_props (self, wp_props_new (WP_PROPS_MODE_CACHE, self)); - klass->enum_params (self, SPA_PARAM_PropInfo, 0, -1, NULL); - klass->subscribe_params (self, ids, SPA_N_ELEMENTS (ids)); + + if (priv->ft_ready & WP_PROXY_FEATURE_INFO) + wp_proxy_enable_feature_props (self); + else + g_signal_connect (self, "notify::param-info", + G_CALLBACK (wp_proxy_enable_feature_props), self); } } -- GitLab