From 92cba34e0b05359fe7a903ad2fb2c0a23e7b801b Mon Sep 17 00:00:00 2001 From: =?utf8?q?Tim-Philipp=20M=C3=BCller?= Date: Sat, 14 Jul 2012 20:28:54 +0100 Subject: [PATCH] plugins: don't use one-time array in plugin_init --- plugins/elements/gstelements.c | 99 +++++++++++++++++++++++------------------- 1 file changed, 55 insertions(+), 44 deletions(-) diff --git a/plugins/elements/gstelements.c b/plugins/elements/gstelements.c index 00594b5..6ba95d0 100644 --- a/plugins/elements/gstelements.c +++ b/plugins/elements/gstelements.c @@ -45,54 +45,65 @@ #include "gsttypefindelement.h" #include "gstvalve.h" -struct _elements_entry -{ - const gchar *name; - guint rank; - GType (*type) (void); -}; - - -static struct _elements_entry _elements[] = { - {"capsfilter", GST_RANK_NONE, gst_capsfilter_get_type}, - {"fakesrc", GST_RANK_NONE, gst_fake_src_get_type}, - {"fakesink", GST_RANK_NONE, gst_fake_sink_get_type}, -#if defined(HAVE_SYS_SOCKET_H) || defined(_MSC_VER) - {"fdsrc", GST_RANK_NONE, gst_fd_src_get_type}, - {"fdsink", GST_RANK_NONE, gst_fd_sink_get_type}, -#endif - {"filesrc", GST_RANK_PRIMARY, gst_file_src_get_type}, - {"funnel", GST_RANK_NONE, gst_funnel_get_type}, - {"identity", GST_RANK_NONE, gst_identity_get_type}, - {"input-selector", GST_RANK_NONE, gst_input_selector_get_type}, - {"output-selector", GST_RANK_NONE, gst_output_selector_get_type}, - {"queue", GST_RANK_NONE, gst_queue_get_type}, - {"queue2", GST_RANK_NONE, gst_queue2_get_type}, - {"filesink", GST_RANK_PRIMARY, gst_file_sink_get_type}, - {"tee", GST_RANK_NONE, gst_tee_get_type}, - {"typefind", GST_RANK_NONE, gst_type_find_element_get_type}, - {"multiqueue", GST_RANK_NONE, gst_multi_queue_get_type}, - {"valve", GST_RANK_NONE, gst_valve_get_type}, - {NULL, 0}, -}; - static gboolean plugin_init (GstPlugin * plugin) { - struct _elements_entry *my_elements = _elements; - - while ((*my_elements).name) { - if (!gst_element_register (plugin, (*my_elements).name, (*my_elements).rank, - ((*my_elements).type) ())) - return FALSE; - my_elements++; - } + if (!gst_element_register (plugin, "capsfilter", GST_RANK_NONE, + gst_capsfilter_get_type ())) + return FALSE; + if (!gst_element_register (plugin, "fakesrc", GST_RANK_NONE, + gst_fake_src_get_type ())) + return FALSE; + if (!gst_element_register (plugin, "fakesink", GST_RANK_NONE, + gst_fake_sink_get_type ())) + return FALSE; +#if defined(HAVE_SYS_SOCKET_H) || defined(_MSC_VER) + if (!gst_element_register (plugin, "fdsrc", GST_RANK_NONE, + gst_fd_src_get_type ())) + return FALSE; + if (!gst_element_register (plugin, "fdsink", GST_RANK_NONE, + gst_fd_sink_get_type ())) + return FALSE; +#endif + if (!gst_element_register (plugin, "filesrc", GST_RANK_PRIMARY, + gst_file_src_get_type ())) + return FALSE; + if (!gst_element_register (plugin, "funnel", GST_RANK_NONE, + gst_funnel_get_type ())) + return FALSE; + if (!gst_element_register (plugin, "identity", GST_RANK_NONE, + gst_identity_get_type ())) + return FALSE; + if (!gst_element_register (plugin, "input-selector", GST_RANK_NONE, + gst_input_selector_get_type ())) + return FALSE; + if (!gst_element_register (plugin, "output-selector", GST_RANK_NONE, + gst_output_selector_get_type ())) + return FALSE; + if (!gst_element_register (plugin, "queue", GST_RANK_NONE, + gst_queue_get_type ())) + return FALSE; + if (!gst_element_register (plugin, "queue2", GST_RANK_NONE, + gst_queue2_get_type ())) + return FALSE; + if (!gst_element_register (plugin, "filesink", GST_RANK_PRIMARY, + gst_file_sink_get_type ())) + return FALSE; + if (!gst_element_register (plugin, "tee", GST_RANK_NONE, gst_tee_get_type ())) + return FALSE; + if (!gst_element_register (plugin, "typefind", GST_RANK_NONE, + gst_type_find_element_get_type ())) + return FALSE; + if (!gst_element_register (plugin, "multiqueue", GST_RANK_NONE, + gst_multi_queue_get_type ())) + return FALSE; + if (!gst_element_register (plugin, "valve", GST_RANK_NONE, + gst_valve_get_type ())) + return FALSE; return TRUE; } -GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, - GST_VERSION_MINOR, - coreelements, - "standard GStreamer elements", - plugin_init, VERSION, GST_LICENSE, GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN); +GST_PLUGIN_DEFINE (GST_VERSION_MAJOR, GST_VERSION_MINOR, coreelements, + " GStreamer core elements", plugin_init, VERSION, GST_LICENSE, + GST_PACKAGE_NAME, GST_PACKAGE_ORIGIN); -- 2.7.4