[gstreamermm] Plug-ins: Speed up initialization by avoiding their loading on startup.
- From: Josà Alburquerque <jaalburqu src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gstreamermm] Plug-ins: Speed up initialization by avoiding their loading on startup.
- Date: Mon, 17 Sep 2012 20:25:57 +0000 (UTC)
commit 648b89f5fe715c7c96a5824df999e9f2acb6f220
Author: Josà Alburquerque <jaalburqu svn gnome org>
Date: Fri Sep 14 16:31:10 2012 -0400
Plug-ins: Speed up initialization by avoiding their loading on startup.
* tools/extra_defs_gen/generate_plugin_gmmproc_file.cc
(generate_hg_file): Use the new _NO_WRAP_INIT_REGISTRATION macro to
signal that the plug-ins should not be registered on startup by the
wrap_init() function. Also use the new _CUSTOM_WRAP_FUNCTION in order
to implement a custom Glib::wrap() function for plug-ins that ensures
the registration of the wrap_new() function before calling
Glib::wrap_auto() to wrap a C object.
(generate_ccg_file): Modify the generation of the plug-in *_get_type()
functions so that when an object of the plug-in type is first created,
the plug-in's wrap_new() function is registered with the wrapping
system using the type obtained when the plug-in is first loaded. Also
generate a custom Glib::wrap() function that ensures the registration
of the plug-in's wrap_new() function before calling Glib::wrap_auto().
This ensures that even if there is a C type of the plug-in, that even
that object can be properly wrapped.
Bug #684006.
ChangeLog | 22 ++++++++++++
.../extra_defs_gen/generate_plugin_gmmproc_file.cc | 36 ++++++++++++++++----
2 files changed, 51 insertions(+), 7 deletions(-)
---
diff --git a/ChangeLog b/ChangeLog
index 978c1f3..6fabe5f 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,25 @@
+2012-09-14 Josà Alburquerque <jaalburquerque gmail com>
+
+ Plug-ins: Speed up initialization by avoiding their loading on startup.
+
+ * tools/extra_defs_gen/generate_plugin_gmmproc_file.cc
+ (generate_hg_file): Use the new _NO_WRAP_INIT_REGISTRATION macro to
+ signal that the plug-ins should not be registered on startup by the
+ wrap_init() function. Also use the new _CUSTOM_WRAP_FUNCTION in order
+ to implement a custom Glib::wrap() function for plug-ins that ensures
+ the registration of the wrap_new() function before calling
+ Glib::wrap_auto() to wrap a C object.
+ (generate_ccg_file): Modify the generation of the plug-in *_get_type()
+ functions so that when an object of the plug-in type is first created,
+ the plug-in's wrap_new() function is registered with the wrapping
+ system using the type obtained when the plug-in is first loaded. Also
+ generate a custom Glib::wrap() function that ensures the registration
+ of the plug-in's wrap_new() function before calling Glib::wrap_auto().
+ This ensures that even if there is a C type of the plug-in, that even
+ that object can be properly wrapped.
+
+ Bug #684006.
+
2012-09-12 Josà Alburquerque <jaalburquerque gmail com>
Event, Message, Query: Have create() methods return derived types.
diff --git a/tools/extra_defs_gen/generate_plugin_gmmproc_file.cc b/tools/extra_defs_gen/generate_plugin_gmmproc_file.cc
index 9eaf3f0..b89d1f9 100644
--- a/tools/extra_defs_gen/generate_plugin_gmmproc_file.cc
+++ b/tools/extra_defs_gen/generate_plugin_gmmproc_file.cc
@@ -648,12 +648,9 @@ static void generate_hg_file(const std::string& includeMacroCalls,
std::cout << enumWrapStatements;
std::cout << "/** A Wrapper for the " << pluginName << " plugin." << std::endl;
- std::cout << " * Please note that, though using the underlying GObject is "
- "fine, using its C\n * <B>type</B> is not guaranteed to be API stable "
- "across releases because it is\n * not guaranteed to always remain the "
- "same. Also, not all plug-ins are\n * available on all systems so care "
- "must be taken that they exist before they\n * are used, otherwise there "
- "will be errors and possibly a crash." << std::endl;
+ std::cout << " * Please note that not all plug-ins are available on all "
+ "systems so care\n * must be taken that they exist before they are used "
+ "otherwise there will\n * be errors and possibly a crash." << std::endl;
std::cout << " *" << std::endl;
std::cout << " * @ingroup " << nmspace << "Plugins" << std::endl;
std::cout << " */" << std::endl;
@@ -673,7 +670,9 @@ static void generate_hg_file(const std::string& includeMacroCalls,
if(!interfaceMacros.empty())
std::cout << interfaceMacros << std::endl;
- std::cout << " _IS_GSTREAMERMM_PLUGIN" << std::endl << std::endl;
+ std::cout << " _IS_GSTREAMERMM_PLUGIN" << std::endl;
+ std::cout << " _NO_WRAP_INIT_REGISTRATION" << std::endl;
+ std::cout << " _CUSTOM_WRAP_FUNCTION" << std::endl << std::endl;
std::cout << "protected:" << std::endl;
std::cout << " " << cppTypeName << "();" << std::endl;
@@ -739,6 +738,9 @@ static void generate_ccg_file(const std::string& enumGTypeFunctionDefinitions,
std::cout << " factory = GST_ELEMENT_FACTORY(feature);" << std::endl;
std::cout << " type = gst_element_factory_get_element_type(factory);" << std::endl;
std::cout << " g_object_unref(factory);" << std::endl;
+ std::cout << std::endl;
+ std::cout << " // Register the new type with wrapping system" << std::endl;
+ std::cout << " Glib::wrap_register(type, &" << nmspace << "::" << cppTypeName << "_Class::wrap_new);" << std::endl;
std::cout << " }" << std::endl;
std::cout << " }" << std::endl << std::endl;
@@ -763,6 +765,26 @@ static void generate_ccg_file(const std::string& enumGTypeFunctionDefinitions,
std::cout << actionSignalsMethodDefinitions;
std::cout << '}' << std::endl;
+
+ // Generate the custom Glib::wrap() function that pre-registers the
+ // wrap_new() function before calling Glib::wrap_auto().
+ std::string returnType = "Glib::RefPtr<" + (std::string) nmspace + "::" + cppTypeName + ">";
+
+ std::cout << "namespace Glib" << std::endl;
+ std::cout << '{' << std::endl << std::endl;
+ std::cout << returnType << " wrap(" << cTypeName << "* object, bool take_copy)" << std::endl;
+ std::cout << '{' << std::endl;
+ std::cout << " static bool registered_wrap_new = false;" << std::endl;
+ std::cout << " if(!registered_wrap_new)" << std::endl;
+ std::cout << " {" << std::endl;
+ std::cout << " // Call get *_get_type() function which does the registration." << std::endl;
+ std::cout << " " << getTypeName << "();" << std::endl;
+ std::cout << " registered_wrap_new = true;" << std::endl;
+ std::cout << " }" << std::endl;
+ std::cout << std::endl;
+ std::cout << " return " << returnType << "( dynamic_cast<" << nmspace << "::" << cppTypeName << "*> (Glib::wrap_auto ((GObject*)(object), take_copy)) );" << std::endl;
+ std::cout << '}' << std::endl << std::endl;
+ std::cout << '}' << std::endl;
}
} // anonymous namespace
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]