mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-12-30 20:20:38 +00:00
devicemonitor: Stop only the already started providers
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>
This commit is contained in:
parent
61703625f6
commit
41677a526b
4 changed files with 31 additions and 2 deletions
|
@ -571,7 +571,8 @@ gst_device_monitor_stop (GstDeviceMonitor * monitor)
|
|||
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);
|
||||
|
||||
|
|
|
@ -55,7 +55,7 @@ struct _GstDeviceProviderPrivate
|
|||
|
||||
GMutex start_lock;
|
||||
|
||||
gboolean started_count;
|
||||
gint started_count;
|
||||
|
||||
GList *hidden_providers;
|
||||
};
|
||||
|
@ -165,6 +165,8 @@ gst_device_provider_init (GstDeviceProvider * provider)
|
|||
|
||||
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);
|
||||
}
|
||||
|
@ -854,3 +856,24 @@ gst_device_provider_device_changed (GstDeviceProvider * provider,
|
|||
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;
|
||||
}
|
||||
|
|
|
@ -139,6 +139,9 @@ GST_API
|
|||
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
|
||||
|
|
|
@ -244,12 +244,14 @@ GST_START_TEST (test_device_provider)
|
|||
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);
|
||||
|
|
Loading…
Reference in a new issue