GNOME Bugzilla – Bug 112745
registry has garbage characters
Last modified: 2004-12-22 21:47:04 UTC
Occasionally, when I run gst-register in an uninstalled HEAD source tree, with GST_PLUGIN_PATH set to the gstreamer tree (and also sometimes with the gst-plugins tree), I will end up with bogus garbage characters in registry.xml in <nametemplate>s: <feature typename="GstElementFactory"> <name>fakesink</name> <longname>Fake Sink</longname> <class>Sink</class> <description>Black hole for data</description> <version>0.7.0.1</version> <author>Erik Walthinsen <omega@cse.ogi.edu></author> <copyright>(C) 1999</copyright> <padtemplate> <nametemplate>XÕ^D^H^A</nametemplate> <direction>sink</direction> <presence>request</presence> </padtemplate> </feature>
Created attachment 16418 [details] complete registry.xml
Ok, I figured out why this happens. Silly me, I was using GST_PLUGIN_PATH=/home/ds/gst/gstreamer, and gst-register would load each plugin *twice*. The problem is that features added to the elementfactory are only ref'd once. When a second factory is added with the same name, the old factory is cleaned in gst_element_factory_cleanup(), which unrefs all the features, thereby destroying them. When the features are added the second time, the same object pointers are used, since they're static variables in the pad template factory functions. Thus destroyed objects are added to the factory. I think the appropriate solution is to make sure that factory functions properly call gst_object_ref(), if they create objects and store the pointer in a static variable. The first place to start is GST_PAD_TEMPLATE_FACTORY(). Because of this, I don't think it's possible to work this solution into 0.6. Instead, I'm fixing gst_element_factory_cleanup() to not unref the features. Comments are welcome.
s/features/padtemplates/
wim, this looks like something you could say what would be the right behaviour :) please comment on this so David can fix it.
Ok, I decided that I was definitely right and fixed it in CVS. Basically, any macro that creates a function that has a static variable now has correct refcounting.