projects
/
platform
/
upstream
/
gstreamer.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
clock: Fix deprecation handling of the GstClock clock field
[platform/upstream/gstreamer.git]
/
gst
/
gstdeviceproviderfactory.c
diff --git
a/gst/gstdeviceproviderfactory.c
b/gst/gstdeviceproviderfactory.c
index
d0586af
..
3fbaa3b
100644
(file)
--- a/
gst/gstdeviceproviderfactory.c
+++ b/
gst/gstdeviceproviderfactory.c
@@
-23,6
+23,7
@@
/**
* SECTION:gstdeviceproviderfactory
/**
* SECTION:gstdeviceproviderfactory
+ * @title: GstDeviceProviderFactory
* @short_description: Create GstDeviceProviders from a factory
* @see_also: #GstDeviceProvider, #GstPlugin, #GstPluginFeature, #GstPadTemplate.
*
* @short_description: Create GstDeviceProviders from a factory
* @see_also: #GstDeviceProvider, #GstPlugin, #GstPluginFeature, #GstPadTemplate.
*
@@
-30,8
+31,9
@@
* GstDeviceProviderfactory can be added to a #GstPlugin as it is also a
* #GstPluginFeature.
*
* GstDeviceProviderfactory can be added to a #GstPlugin as it is also a
* #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
+ * Use the gst_device_provider_factory_find() and
+ * 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
* convenient shortcut.
*
* Since: 1.4
@@
-195,9
+197,7
@@
gst_device_provider_register (GstPlugin * plugin, const gchar * name,
return TRUE;
}
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));
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));
@@
-274,14
+274,15
@@
gst_device_provider_factory_get (GstDeviceProviderFactory * factory)
goto no_type;
device_provider = g_atomic_pointer_get (&newfactory->provider);
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);
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
*/
/* 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;
if (G_UNLIKELY (device_provider == NULL))
goto no_device_provider;
@@
-291,8
+292,12
@@
gst_device_provider_factory_get (GstDeviceProviderFactory * factory)
* an device provider at the same moment
*/
oclass = GST_DEVICE_PROVIDER_GET_CLASS (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);
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);
gst_object_ref_sink (device_provider);
@@
-387,8
+392,7
@@
create_failed:
* only be retrieved if the device provider factory is loaded, which can be
* assured with gst_plugin_feature_load().
*
* 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
*/
*
* Since: 1.4
*/
@@
-396,7
+400,8
@@
GType
gst_device_provider_factory_get_device_provider_type (GstDeviceProviderFactory *
factory)
{
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;
}
return factory->type;
}
@@
-461,8
+466,8
@@
gst_device_provider_factory_get_metadata_keys (GstDeviceProviderFactory *
/**
* gst_device_provider_factory_has_classesv:
* @factory: a #GstDeviceProviderFactory
/**
* gst_device_provider_factory_has_classesv:
* @factory: a #GstDeviceProviderFactory
- * @classes: (array zero-terminated=1)
: a %NULL terminated array of
- *
k
lasses to match, only match if all classes are matched
+ * @classes: (array zero-terminated=1)
(allow-none): a %NULL terminated array
+ *
of c
lasses to match, only match if all classes are matched
*
* Check if @factory matches all of the given classes
*
*
* Check if @factory matches all of the given classes
*
@@
-487,11
+492,11
@@
gst_device_provider_factory_has_classesv (GstDeviceProviderFactory * factory,
return FALSE;
}
return FALSE;
}
- for (; classes
[0]
; classes++) {
+ for (; classes
!= NULL && classes[0] != NULL
; classes++) {
const gchar *found;
guint len;
const gchar *found;
guint len;
- if (classes[0] == '\0')
+ if (classes[0]
[0]
== '\0')
continue;
found = strstr (klass, classes[0]);
continue;
found = strstr (klass, classes[0]);
@@
-512,12
+517,12
@@
gst_device_provider_factory_has_classesv (GstDeviceProviderFactory * factory,
/**
* gst_device_provider_factory_has_classes:
* @factory: a #GstDeviceProviderFactory
/**
* 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
*
*
* 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
*/
*
* Since: 1.4
*/
@@
-528,6
+533,9
@@
gst_device_provider_factory_has_classes (GstDeviceProviderFactory * factory,
gchar **classesv;
gboolean res;
gchar **classesv;
gboolean res;
+ if (classes == NULL)
+ return TRUE;
+
classesv = g_strsplit (classes, "/", 0);
res = gst_device_provider_factory_has_classesv (factory, classesv);
classesv = g_strsplit (classes, "/", 0);
res = gst_device_provider_factory_has_classesv (factory, classesv);
@@
-537,57
+545,37
@@
gst_device_provider_factory_has_classes (GstDeviceProviderFactory * factory,
return res;
}
return res;
}
-typedef struct
-{
- const char *classes;
- GstRank minrank;
-} FilterData;
-
static gboolean
static gboolean
-device_provider_filter (GstPluginFeature * feature,
FilterData * data
)
+device_provider_filter (GstPluginFeature * feature,
GstRank * minrank
)
{
{
- gboolean res;
-
/* we only care about device provider factories */
if (G_UNLIKELY (!GST_IS_DEVICE_PROVIDER_FACTORY (feature)))
return FALSE;
/* we only care about device provider factories */
if (G_UNLIKELY (!GST_IS_DEVICE_PROVIDER_FACTORY (feature)))
return FALSE;
- res = (gst_plugin_feature_get_rank (feature) >= data->minrank) &&
- gst_device_provider_factory_has_classes (GST_DEVICE_PROVIDER_FACTORY_CAST
- (feature), data->classes);
-
- return res;
+ return (gst_plugin_feature_get_rank (feature) >= *minrank);
}
/**
* gst_device_provider_factory_list_get_device_providers:
}
/**
* gst_device_provider_factory_list_get_device_providers:
- * @classes: a "/" separate list of klasses to match, only match if all classes
- * are matched
* @minrank: Minimum rank
*
* @minrank: Minimum rank
*
- * Get a list of factories that match all of the given @classes. Only
- * device providers with a rank greater or equal to @minrank will be
- * returned. The list of factories is returned by decreasing rank.
+ * Get a list of factories with a rank greater or equal to @minrank.
+ * The list of factories is returned by decreasing rank.
*
*
- * Returns: (transfer full) (element-type Gst.DeviceProviderFactory):
a #GList of
- *
#GstDeviceProviderFactory device providers. Use gst_plugin_feature_list_free() after
- *
usage.
+ * Returns: (transfer full) (element-type Gst.DeviceProviderFactory):
+ *
a #GList of #GstDeviceProviderFactory device providers. Use
+ *
gst_plugin_feature_list_free() after
usage.
*
* Since: 1.4
*/
*
* Since: 1.4
*/
-GList *
gst_device_provider_factory_list_get_device_providers
-
(const gchar * classes,
GstRank minrank)
+GList *
+
gst_device_provider_factory_list_get_device_providers (
GstRank minrank)
{
GList *result;
{
GList *result;
- FilterData data;
-
- /* prepare type */
- data.classes = classes;
- data.minrank = minrank;
/* get the feature list using the filter */
result = gst_registry_feature_filter (gst_registry_get (),
/* get the feature list using the filter */
result = gst_registry_feature_filter (gst_registry_get (),
- (GstPluginFeatureFilter) device_provider_filter, FALSE, &
data
);
+ (GstPluginFeatureFilter) device_provider_filter, FALSE, &
minrank
);
/* sort on rank and name */
result = g_list_sort (result, gst_plugin_feature_rank_compare_func);
/* sort on rank and name */
result = g_list_sort (result, gst_plugin_feature_rank_compare_func);