GNOME Bugzilla – Bug 570233
allow plugins caching data in the registry
Last modified: 2009-06-07 20:52:40 UTC
the audio resampler runs a small benchmark every time the plugin_init is called. besides from delaying this for when its actually needed, it would be nice if the element could check if the registry has this cached, if not compute it and cache it.
Other usecases could be: * caching device properties for hardware related sinks and sources * caching connection parameters for stream sources (for servers) I think it would be even okay to reset the cache when core is bumped. This way we avoid accumullation of cache data)
Sounds like a very good idea... this should probably be stored as a key-value list/array where the keys are normal strings and the values are GValues that we serialize to strings for storing inside the registry.
You mean a GstStructure :)
Err... yes, a serialized GstStructure containing no pointer/boxed GValues ;)
One more place where this is handy would we sub-registries. Try this; GST_DEBUG="ladspa:4" gst-launch ladspa-sawtooth-fa-oa ! audioconvert ! autoaudiosink Everytime one instantiates a wrapper plugin the first time it scans the plugins once again. Not sure if this case could be handled with a (nested) GstStructure too (should be okay).
It can handled simillar to uri-handler iface in registry. Instead of GstElementFactory (in the uri-handler case) we would extend GstPluginFeature to have a GstStructure *extra_data; and add _set/get functions. Plugins would need to access or produce this data in plugin_init(). GstPluginFeature *my_feature; GstStructure *data; /* getting the feature from the plugin itself would be useful */ my_feature = gst_registry_lookup_feature( gst_registry_get_default(), "my-plugin"); data = gst_plugin_feature_get_extra_data (my_feature); if(!data) { /* we are running in registry update */ data = gather_data(...); gst_plugin_feature_set_extra_data (my_feature, data); } /* use the cache data */ register_elements (plugin, data);
Inside the binary registry this is eary to be implemented using: gchar *gst_structure_to_string (const GstStructure *structure); GstStructure *gst_structure_from_string(const gchar *string, gchar **end);
Created attachment 136067 [details] [review] add cache_data to GstPlugin Do it in GstPlugin and not GstPluginFeature. This way we don'T need to lookup the feature in plugin_init, which would not work anyway (is NULL).
Same patch as before, but make the returned GStStructure const and add new API to win32/def file. commit ed88db818b64982adcdcc29e88ad476358a0757d Author: Stefan Kost <ensonic@users.sf.net> Date: Sun Jun 7 23:46:54 2009 +0300 registry: allow plugins to cache extra data in registry. Fixes #570233 Add a GstStructure to GstPlugin. Plugins can retieve it in plugin_init and access the cached info or build the cache and store it there.