GNOME Bugzilla – Bug 584389
don't recreate plugin feature and element factories on first use
Last modified: 2009-06-07 20:55:35 UTC
GST_DEBUG_NO_COLOR=1 GST_DEBUG="GST_REGISTRY:4" gst-launch 2>debug.log audiotestsrc num-buffers=1 ! pulsesink grep "replacing" debug.log gstregistry.c:447:gst_registry_add_feature:<registry0> replacing existing feature 0x80ebf50 (audiotestsrc) gstregistry.c:447:gst_registry_add_feature:<registry0> replacing existing feature 0x81a2890 (pulsesink) ... basically, the first time we call gst_element_factory_make(), we recreate the plugin feature and the element factory. As a side effect we ref the class to fill in detail we already have filled from the registry cache. This is bad for wrapper plugins like ladspa, as creating the first ladspa element would load *all* ladspa *so (as it invokes the class init for each type). The attached patch changes the behaviour to not thow the features away, but update them. It won't ref the class anymore. This has the side-effect that it can't fill klass->elementfactory = factory in gst_element_register() anymore and thus relies on gst_element_factory_create() setting it (and this has a FIXME: about thread safty). I'd like to post this here for discussion and review.
Forgot to mention that it make one test fails: gst/gstelement.c:201:F:element tests:test_class:0: Failure 'klass->elementfactory == NULL' occured
Created attachment 135685 [details] [review] reuse plugin feature and element factories on first use
Created attachment 135716 [details] [review] reuse plugin feature and element factories on first use This make setting the factory gst_element_factory_create() atomic. Whats the thinking about the failing test in gst/gstelement.c::201 test_class()?
There are two uses of class->elementfactory and both are from an instance where this is defined (gst_element_get_factory() and gst_element_save_thyself()).
Created attachment 135812 [details] [review] reuse plugin feature and element factories on first use don't unref the class when finalizing, as we don't ref it anymore
*** Bug 571604 has been marked as a duplicate of this bug. ***
Almost the same as the last patch, except that now the tests pass unmodified. commit 55577a48ea9e93ec6532b1e81684e4c0ae26157c Author: Stefan Kost <ensonic@users.sf.net> Date: Sun Jun 7 22:09:14 2009 +0300 registry: don't recreate features on first use. Fixes #584389 The first time one calls gst_element_factory_make(), gst recreates the plugin feature and the element factory. As a side effect we ref the class to fill in detail we already have filled from the registry cache. This patch changes the behaviour to just update the existing entries. The factory is now attached to the type and set in gst_element_base_class_init().