From c173b23ac422bd3e745407bd8c543920f150e4aa Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Mon, 13 Jul 2020 12:31:16 +0200 Subject: [PATCH] gst: use object_path to hide providers Don't use the core info to manage the hiden providers, that info can't be put there anymore because the session manager manages the devices now. Look at the object path instead and hide those with well known prefixes. --- src/gst/gstpipewiredeviceprovider.c | 43 +++++++++-------------------- 1 file changed, 13 insertions(+), 30 deletions(-) diff --git a/src/gst/gstpipewiredeviceprovider.c b/src/gst/gstpipewiredeviceprovider.c index ca7f73068..d3eb940fc 100644 --- a/src/gst/gstpipewiredeviceprovider.c +++ b/src/gst/gstpipewiredeviceprovider.c @@ -296,33 +296,6 @@ static void remove_pending(struct pending *p) } } -static void -on_core_info (void *data, const struct pw_core_info *info) -{ - GstPipeWireDeviceProvider *self = data; - GstDeviceProvider *provider = (GstDeviceProvider*)self; - const gchar *value; - - if (info == NULL || info->props == NULL) - return; - - value = spa_dict_lookup (info->props, PW_KEY_CORE_MONITORS); - if (value) { - gchar **monitors = g_strsplit (value, ",", -1); - gint i; - - GST_DEBUG_OBJECT (provider, "have hidden providers: %s", value); - - for (i = 0; monitors[i]; i++) { - if (strcmp (monitors[i], "v4l2") == 0) - gst_device_provider_hide_provider (provider, "v4l2deviceprovider"); - else if (strcmp (monitors[i], "alsa") == 0) - gst_device_provider_hide_provider (provider, "pulsedeviceprovider"); - } - g_strfreev (monitors); - } -} - static void on_core_done (void *data, uint32_t id, int seq) { @@ -353,7 +326,7 @@ on_core_error(void *data, uint32_t id, int seq, int res, const char *message) pw_log_error("error id:%u seq:%d res:%d (%s): %s", id, seq, res, spa_strerror(res), message); - if (id == 0) { + if (id == PW_ID_CORE) { self->error = res; } pw_thread_loop_signal(self->loop, FALSE); @@ -361,7 +334,6 @@ on_core_error(void *data, uint32_t id, int seq, int res, const char *message) static const struct pw_core_events core_events = { PW_VERSION_CORE_EVENTS, - .info = on_core_info, .done = on_core_done, .error = on_core_error, }; @@ -467,7 +439,9 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions, { struct core_data *rd = data; GstPipeWireDeviceProvider *self = rd->self; + GstDeviceProvider *provider = (GstDeviceProvider*)self; struct node_data *nd; + const char *str; if (strcmp(type, PW_TYPE_INTERFACE_Node) == 0) { struct pw_node *node; @@ -477,6 +451,16 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions, if (node == NULL) goto no_mem; + if (props != NULL) { + str = spa_dict_lookup(props, PW_KEY_OBJECT_PATH); + if (str != NULL) { + if (g_str_has_prefix(str, "alsa:")) + gst_device_provider_hide_provider (provider, "pulsedeviceprovider"); + else if (g_str_has_prefix(str, "v4l2:")) + gst_device_provider_hide_provider (provider, "v4l2deviceprovider"); + } + } + nd = pw_proxy_get_user_data((struct pw_proxy*)node); nd->self = self; nd->proxy = node; @@ -490,7 +474,6 @@ static void registry_event_global(void *data, uint32_t id, uint32_t permissions, else if (strcmp(type, PW_TYPE_INTERFACE_Port) == 0) { struct pw_port *port; struct port_data *pd; - const char *str; if ((str = spa_dict_lookup(props, PW_KEY_NODE_ID)) == NULL) return;