/**
* SECTION:gstdeviceproviderfactory
+ * @title: GstDeviceProviderFactory
* @short_description: Create GstDeviceProviders from a factory
* @see_also: #GstDeviceProvider, #GstPlugin, #GstPluginFeature, #GstPadTemplate.
*
* #GstPluginFeature.
*
* Use the gst_device_provider_factory_find() and
- * gst_device_provider_factory_create() functions to create device
- * provider instances or use gst_device_provider_factory_make() as a
+ * gst_device_provider_factory_get() functions to create device
+ * provider instances or use gst_device_provider_factory_get_by_name() as a
* convenient shortcut.
*
* Since: 1.4
return TRUE;
}
- factory =
- GST_DEVICE_PROVIDER_FACTORY_CAST (g_object_newv
- (GST_TYPE_DEVICE_PROVIDER_FACTORY, 0, NULL));
+ factory = g_object_new (GST_TYPE_DEVICE_PROVIDER_FACTORY, NULL);
gst_plugin_feature_set_name (GST_PLUGIN_FEATURE_CAST (factory), name);
GST_LOG_OBJECT (factory, "Created new device providerfactory for type %s",
g_type_name (type));
goto no_type;
device_provider = g_atomic_pointer_get (&newfactory->provider);
- if (device_provider)
+ if (device_provider) {
+ gst_object_unref (factory);
return gst_object_ref (device_provider);
+ }
/* create an instance of the device provider, cast so we don't assert on NULL
* also set name as early as we can
*/
- device_provider = GST_DEVICE_PROVIDER_CAST (g_object_newv (factory->type, 0,
- NULL));
+ device_provider = g_object_new (factory->type, NULL);
if (G_UNLIKELY (device_provider == NULL))
goto no_device_provider;
* an device provider at the same moment
*/
oclass = GST_DEVICE_PROVIDER_GET_CLASS (device_provider);
- if (!g_atomic_pointer_compare_and_exchange (&oclass->factory, NULL, factory))
+ if (!g_atomic_pointer_compare_and_exchange (&oclass->factory, NULL, factory)) {
gst_object_unref (factory);
+ } else {
+ /* This ref will never be dropped as the class is never destroyed */
+ GST_OBJECT_FLAG_SET (factory, GST_OBJECT_FLAG_MAY_BE_LEAKED);
+ }
gst_object_ref_sink (device_provider);
* only be retrieved if the device provider factory is loaded, which can be
* assured with gst_plugin_feature_load().
*
- * Returns: the #GType for device providers managed by this factory or 0 if
- * the factory is not loaded.
+ * Returns: the #GType for device providers managed by this factory.
*
* Since: 1.4
*/
gst_device_provider_factory_get_device_provider_type (GstDeviceProviderFactory *
factory)
{
- g_return_val_if_fail (GST_IS_DEVICE_PROVIDER_FACTORY (factory), 0);
+ g_return_val_if_fail (GST_IS_DEVICE_PROVIDER_FACTORY (factory),
+ G_TYPE_INVALID);
return factory->type;
}
/**
* gst_device_provider_factory_has_classesv:
* @factory: a #GstDeviceProviderFactory
- * @classes: (array zero-terminated=1): a %NULL terminated array of
- * klasses to match, only match if all classes are matched
+ * @classes: (array zero-terminated=1) (allow-none): a %NULL terminated array
+ * of classes to match, only match if all classes are matched
*
* Check if @factory matches all of the given classes
*
return FALSE;
}
- for (; classes[0]; classes++) {
+ for (; classes != NULL && classes[0] != NULL; classes++) {
const gchar *found;
guint len;
- if (classes[0] == '\0')
+ if (classes[0][0] == '\0')
continue;
found = strstr (klass, classes[0]);
/**
* gst_device_provider_factory_has_classes:
* @factory: a #GstDeviceProviderFactory
- * @classes: a "/" separate list of klasses to match, only match if all classes
- * are matched
+ * @classes: (allow-none): a "/" separate list of classes to match, only match
+ * if all classes are matched
*
* Check if @factory matches all of the given @classes
*
- * Returns: %TRUE if @factory matches.
+ * Returns: %TRUE if @factory matches or if @classes is %NULL.
*
* Since: 1.4
*/
gchar **classesv;
gboolean res;
+ if (classes == NULL)
+ return TRUE;
+
classesv = g_strsplit (classes, "/", 0);
res = gst_device_provider_factory_has_classesv (factory, classesv);