If a device provider fails to start (for instance the pulseaudio provider unable
to connect to the PulseAudio daemon) then the monitor should not keep track of
it in its `started` providers list. Otherwise a false positive critical warning
would be raised.
This patch also switches the started_count type from bool to int, for
consistency. This is a counter, after all.
API: gst_device_provider_is_started
Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/679>
GstDeviceProvider *provider =
g_ptr_array_index (monitor->priv->providers, i);
- started = g_list_prepend (started, gst_object_ref (provider));
+ if (gst_device_provider_is_started (provider))
+ started = g_list_prepend (started, gst_object_ref (provider));
}
GST_OBJECT_UNLOCK (monitor);
GMutex start_lock;
- gboolean started_count;
+ gint started_count;
GList *hidden_providers;
};
g_mutex_init (&provider->priv->start_lock);
+ provider->priv->started_count = 0;
+
provider->priv->bus = gst_bus_new ();
gst_bus_set_flushing (provider->priv->bus, TRUE);
}
gst_bus_post (provider->priv->bus, message);
gst_object_unparent (GST_OBJECT (changed_device));
}
+
+/**
+ * gst_device_provider_is_started:
+ * @provider: a #GstDeviceProvider
+ *
+ * This function can be used to know if the @provider was successfully started.
+ *
+ * Since: 1.20
+ */
+gboolean
+gst_device_provider_is_started (GstDeviceProvider * provider)
+{
+ gboolean started = FALSE;
+
+ g_return_val_if_fail (GST_IS_DEVICE_PROVIDER (provider), FALSE);
+
+ g_mutex_lock (&provider->priv->start_lock);
+ started = provider->priv->started_count > 0;
+ g_mutex_unlock (&provider->priv->start_lock);
+ return started;
+}
const gchar * gst_device_provider_get_metadata (GstDeviceProvider * provider,
const gchar * key);
+GST_API
+gboolean gst_device_provider_is_started (GstDeviceProvider * provider);
+
/* device provider class meta data */
GST_API
g_list_free_full (devs, (GDestroyNotify) gst_object_unref);
fail_if (gst_device_provider_can_monitor (dp));
+ fail_if (gst_device_provider_is_started (dp));
fail_unless (gst_device_provider_start (dp));
bus = gst_device_provider_get_bus (dp);
fail_unless (GST_IS_BUS (bus));
gst_object_unref (bus);
+ fail_unless (gst_device_provider_is_started (dp));
gst_device_provider_stop (dp);
gst_object_unref (dp);