mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-07-11 09:06:05 +00:00
typefind: Keep typefind factories sorted in the registry. Fixes #599147
This avoids having to do the sorting everytime we use typefind The behaviour of gst_type_find_factory_get_list has subtlely changed in the sense that the order was previously undefined, whereas now it returns them sorted by rank and then by name.
This commit is contained in:
parent
c79ed99bab
commit
5067664c09
|
@ -635,6 +635,18 @@ gst_registry_get_feature_list_or_create (GstRegistry * registry,
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static gint
|
||||||
|
type_find_factory_rank_cmp (const GstPluginFeature * fac1,
|
||||||
|
const GstPluginFeature * fac2)
|
||||||
|
{
|
||||||
|
if (G_LIKELY (fac1->rank != fac2->rank))
|
||||||
|
return fac2->rank - fac1->rank;
|
||||||
|
|
||||||
|
/* to make the order in which things happen more deterministic,
|
||||||
|
* sort by name when the ranks are the same. */
|
||||||
|
return strcmp (fac1->name, fac2->name);
|
||||||
|
}
|
||||||
|
|
||||||
static GList *
|
static GList *
|
||||||
gst_registry_get_element_factory_list (GstRegistry * registry)
|
gst_registry_get_element_factory_list (GstRegistry * registry)
|
||||||
{
|
{
|
||||||
|
@ -661,9 +673,12 @@ gst_registry_get_typefind_factory_list (GstRegistry * registry)
|
||||||
|
|
||||||
GST_OBJECT_LOCK (registry);
|
GST_OBJECT_LOCK (registry);
|
||||||
|
|
||||||
gst_registry_get_feature_list_or_create (registry,
|
if (G_UNLIKELY (gst_registry_get_feature_list_or_create (registry,
|
||||||
®istry->private->typefind_factory_list,
|
®istry->private->typefind_factory_list,
|
||||||
®istry->private->tfl_cookie, GST_TYPE_TYPE_FIND_FACTORY);
|
®istry->private->tfl_cookie, GST_TYPE_TYPE_FIND_FACTORY)))
|
||||||
|
registry->private->typefind_factory_list =
|
||||||
|
g_list_sort (registry->private->typefind_factory_list,
|
||||||
|
(GCompareFunc) type_find_factory_rank_cmp);
|
||||||
|
|
||||||
/* Return reffed copy */
|
/* Return reffed copy */
|
||||||
list =
|
list =
|
||||||
|
|
|
@ -146,6 +146,9 @@ gst_type_find_factory_dispose (GObject * object)
|
||||||
* Gets the list of all registered typefind factories. You must free the
|
* Gets the list of all registered typefind factories. You must free the
|
||||||
* list using gst_plugin_feature_list_free.
|
* list using gst_plugin_feature_list_free.
|
||||||
*
|
*
|
||||||
|
* The returned factories are sorted by highest rank first, and then by
|
||||||
|
* factory name. (behaviour change since 0.10.26)
|
||||||
|
*
|
||||||
* Returns: the list of all registered #GstTypeFindFactory.
|
* Returns: the list of all registered #GstTypeFindFactory.
|
||||||
*/
|
*/
|
||||||
GList *
|
GList *
|
||||||
|
|
|
@ -40,18 +40,6 @@
|
||||||
|
|
||||||
#include "gsttypefindhelper.h"
|
#include "gsttypefindhelper.h"
|
||||||
|
|
||||||
static gint
|
|
||||||
type_find_factory_rank_cmp (const GstPluginFeature * fac1,
|
|
||||||
const GstPluginFeature * fac2)
|
|
||||||
{
|
|
||||||
if (G_LIKELY (fac1->rank != fac2->rank))
|
|
||||||
return fac2->rank - fac1->rank;
|
|
||||||
|
|
||||||
/* to make the order in which things happen more deterministic,
|
|
||||||
* sort by name when the ranks are the same. */
|
|
||||||
return strcmp (fac1->name, fac2->name);
|
|
||||||
}
|
|
||||||
|
|
||||||
/* ********************** typefinding in pull mode ************************ */
|
/* ********************** typefinding in pull mode ************************ */
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
@ -279,10 +267,7 @@ gst_type_find_helper_get_range (GstObject * obj,
|
||||||
find.get_length = helper_find_get_length;
|
find.get_length = helper_find_get_length;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* FIXME: we need to keep this list within the registry */
|
|
||||||
type_list = gst_type_find_factory_get_list ();
|
type_list = gst_type_find_factory_get_list ();
|
||||||
type_list =
|
|
||||||
g_list_sort (type_list, (GCompareFunc) type_find_factory_rank_cmp);
|
|
||||||
|
|
||||||
for (l = type_list; l; l = l->next) {
|
for (l = type_list; l; l = l->next) {
|
||||||
helper.factory = GST_TYPE_FIND_FACTORY (l->data);
|
helper.factory = GST_TYPE_FIND_FACTORY (l->data);
|
||||||
|
@ -456,8 +441,6 @@ gst_type_find_helper_for_buffer (GstObject * obj, GstBuffer * buf,
|
||||||
|
|
||||||
/* FIXME: we need to keep this list within the registry */
|
/* FIXME: we need to keep this list within the registry */
|
||||||
type_list = gst_type_find_factory_get_list ();
|
type_list = gst_type_find_factory_get_list ();
|
||||||
type_list =
|
|
||||||
g_list_sort (type_list, (GCompareFunc) type_find_factory_rank_cmp);
|
|
||||||
|
|
||||||
for (l = type_list; l; l = l->next) {
|
for (l = type_list; l; l = l->next) {
|
||||||
helper.factory = GST_TYPE_FIND_FACTORY (l->data);
|
helper.factory = GST_TYPE_FIND_FACTORY (l->data);
|
||||||
|
@ -506,8 +489,6 @@ gst_type_find_helper_for_extension (GstObject * obj, const gchar * extension)
|
||||||
GST_LOG_OBJECT (obj, "finding caps for extension %s", extension);
|
GST_LOG_OBJECT (obj, "finding caps for extension %s", extension);
|
||||||
|
|
||||||
type_list = gst_type_find_factory_get_list ();
|
type_list = gst_type_find_factory_get_list ();
|
||||||
type_list =
|
|
||||||
g_list_sort (type_list, (GCompareFunc) type_find_factory_rank_cmp);
|
|
||||||
|
|
||||||
for (l = type_list; l; l = g_list_next (l)) {
|
for (l = type_list; l; l = g_list_next (l)) {
|
||||||
GstTypeFindFactory *factory;
|
GstTypeFindFactory *factory;
|
||||||
|
|
Loading…
Reference in a new issue