subtitleoverlay: Only recreate factory caps if necessary and cache them

This commit is contained in:
Sebastian Dröge 2009-11-11 17:08:47 +01:00
parent 068aecc389
commit 7827660dcd

View file

@ -304,18 +304,32 @@ gst_subtitle_overlay_update_factory_list (GstSubtitleOverlay * self)
return (self->factories != NULL); return (self->factories != NULL);
} }
G_LOCK_DEFINE_STATIC (_factory_caps);
static GstCaps *_factory_caps = NULL;
static guint32 _factory_caps_cookie = 0;
GstCaps * GstCaps *
gst_subtitle_overlay_create_factory_caps (void) gst_subtitle_overlay_create_factory_caps (void)
{ {
GList *factories; GList *factories;
GstCaps *subcaps; GstCaps *subcaps = NULL;
subcaps = gst_caps_new_empty (); G_LOCK (_factory_caps);
if (!_factory_caps
|| _factory_caps_cookie !=
gst_default_registry_get_feature_list_cookie ()) {
if (_factory_caps)
gst_caps_unref (_factory_caps);
_factory_caps = gst_caps_new_empty ();
factories = gst_default_registry_feature_filter ( factories = gst_default_registry_feature_filter (
(GstPluginFeatureFilter) _factory_filter, FALSE, &subcaps); (GstPluginFeatureFilter) _factory_filter, FALSE, &_factory_caps);
GST_DEBUG ("Created factory caps: %" GST_PTR_FORMAT, subcaps); GST_DEBUG ("Created factory caps: %" GST_PTR_FORMAT, _factory_caps);
gst_plugin_feature_list_free (factories); gst_plugin_feature_list_free (factories);
_factory_caps_cookie = gst_default_registry_get_feature_list_cookie ();
}
subcaps = gst_caps_ref (_factory_caps);
G_UNLOCK (_factory_caps);
return subcaps; return subcaps;
} }