registry: also intern the static caps

This commit is contained in:
Stefan Kost 2010-10-18 13:29:53 +03:00
parent 2d17d86ba8
commit d370a2437a
2 changed files with 5 additions and 4 deletions

View file

@ -163,8 +163,6 @@ gst_element_factory_cleanup (GstElementFactory * factory)
GstStaticPadTemplate *templ = item->data; GstStaticPadTemplate *templ = item->data;
GstCaps *caps = (GstCaps *) & (templ->static_caps); GstCaps *caps = (GstCaps *) & (templ->static_caps);
g_free ((gchar *) templ->static_caps.string);
/* FIXME: this is not threadsafe */ /* FIXME: this is not threadsafe */
if (caps->refcount == 1) { if (caps->refcount == 1) {
GstStructure *structure; GstStructure *structure;
@ -264,15 +262,18 @@ gst_element_register (GstPlugin * plugin, const gchar * name, guint rank,
for (item = klass->padtemplates; item; item = item->next) { for (item = klass->padtemplates; item; item = item->next) {
GstPadTemplate *templ = item->data; GstPadTemplate *templ = item->data;
GstStaticPadTemplate *newt; GstStaticPadTemplate *newt;
gchar *caps_string = gst_caps_to_string (templ->caps);
newt = g_slice_new (GstStaticPadTemplate); newt = g_slice_new (GstStaticPadTemplate);
newt->name_template = g_intern_string (templ->name_template); newt->name_template = g_intern_string (templ->name_template);
newt->direction = templ->direction; newt->direction = templ->direction;
newt->presence = templ->presence; newt->presence = templ->presence;
newt->static_caps.caps.refcount = 0; newt->static_caps.caps.refcount = 0;
newt->static_caps.string = gst_caps_to_string (templ->caps); newt->static_caps.string = g_intern_string (caps_string);
factory->staticpadtemplates = factory->staticpadtemplates =
g_list_append (factory->staticpadtemplates, newt); g_list_append (factory->staticpadtemplates, newt);
g_free (caps_string);
} }
factory->numpadtemplates = klass->numpadtemplates; factory->numpadtemplates = klass->numpadtemplates;

View file

@ -505,7 +505,7 @@ gst_registry_chunks_load_pad_template (GstElementFactory * factory, gchar ** in,
/* unpack pad template strings */ /* unpack pad template strings */
unpack_const_string (*in, template->name_template, end, fail); unpack_const_string (*in, template->name_template, end, fail);
unpack_string (*in, template->static_caps.string, end, fail); unpack_const_string (*in, template->static_caps.string, end, fail);
__gst_element_factory_add_static_pad_template (factory, template); __gst_element_factory_add_static_pad_template (factory, template);
GST_DEBUG ("Added pad_template %s", template->name_template); GST_DEBUG ("Added pad_template %s", template->name_template);