static void fetch_element_table (GstPlugin * plugin) { gchar *path; gchar *config, *s; GstStructure *tmp, *element; element_table = gst_plugin_get_cache_data (plugin); if (element_table) return; path = get_config_path (); if (!g_file_get_contents (path, &config, NULL, NULL)) { g_warning ("could not find config file '%s'.. using defaults!", path); config = (gchar *) default_config; } gst_plugin_add_dependency_simple (plugin, "ONX_CONFIG", path, NULL, GST_PLUGIN_DEPENDENCY_FLAG_NONE); g_free (path); GST_DEBUG ("parsing config:\n%s", config); tmp = gst_structure_empty_new ("element_table"); s = config; while ((element = gst_structure_from_string (s, &s))) { const gchar *element_name = gst_structure_get_name (element); gst_structure_set (tmp, element_name, GST_TYPE_STRUCTURE, element, NULL); } if (config != default_config) g_free (config); GST_DEBUG ("element_table=%" GST_PTR_FORMAT, tmp); gst_plugin_set_cache_data (plugin, tmp); element_table = tmp; }
static gboolean plugin_init (GstPlugin * plugin) { gboolean res = FALSE; gint n = 0; GST_DEBUG_CATEGORY_INIT (ladspa_debug, "ladspa", 0, "LADSPA plugins"); #ifdef ENABLE_NLS GST_DEBUG_OBJECT (plugin, "binding text domain %s to locale dir %s", GETTEXT_PACKAGE, LOCALEDIR); bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); bind_textdomain_codeset (GETTEXT_PACKAGE, "UTF-8"); #endif gst_plugin_add_dependency_simple (plugin, "LADSPA_PATH", GST_LADSPA_DEFAULT_PATH, NULL, GST_PLUGIN_DEPENDENCY_FLAG_NONE); #ifdef HAVE_LRDF lrdf_init (); #endif ladspa_meta_all = (GstStructure *) gst_plugin_get_cache_data (plugin); if (ladspa_meta_all) { n = gst_structure_n_fields (ladspa_meta_all); } GST_INFO_OBJECT (plugin, "%d entries in cache", n); if (!n) { ladspa_meta_all = gst_structure_new_empty ("ladspa"); if ((res = ladspa_plugin_path_search (plugin))) { n = gst_structure_n_fields (ladspa_meta_all); GST_INFO_OBJECT (plugin, "%d entries after scanning", n); gst_plugin_set_cache_data (plugin, ladspa_meta_all); } } else { res = TRUE; } if (n) { gint i; const gchar *name; const GValue *value; GST_INFO_OBJECT (plugin, "register types"); for (i = 0; i < n; i++) { name = gst_structure_nth_field_name (ladspa_meta_all, i); value = gst_structure_get_value (ladspa_meta_all, name); if (G_VALUE_TYPE (value) == GST_TYPE_STRUCTURE) { GstStructure *ladspa_meta = g_value_get_boxed (value); ladspa_plugin_register_element (plugin, ladspa_meta); } } } if (!res) { GST_WARNING_OBJECT (plugin, "no LADSPA plugins found, check LADSPA_PATH"); } /* we don't want to fail, even if there are no elements registered */ return TRUE; }