diff src/audacious/pluginenum.c @ 2623:0ad10a95ed10 trunk

[svn] - plugin reloading.
author nenolod
date Thu, 15 Mar 2007 19:25:27 -0700
parents 4daf4fa409e0
children 840fb578a834
line wrap: on
line diff
--- a/src/audacious/pluginenum.c	Thu Mar 15 18:44:52 2007 -0700
+++ b/src/audacious/pluginenum.c	Thu Mar 15 19:25:27 2007 -0700
@@ -58,6 +58,8 @@
 GHashTable *plugin_matrix = NULL;
 GList *lowlevel_list = NULL;
 
+extern GList *vfs_transports;
+
 static gint
 inputlist_compare_func(gconstpointer a, gconstpointer b)
 {
@@ -219,6 +221,8 @@
     if (plugin_is_duplicate(filename))
         return;
 
+    g_message("Loaded plugin (%s)", filename);
+
     if (!(module = g_module_open(filename, G_MODULE_BIND_LOCAL))) {
         printf("Failed to load plugin (%s): %s\n", 
                   filename, g_module_error());
@@ -397,6 +401,9 @@
         ip_data.stop = FALSE;
     }
 
+    /* FIXME: race condition -nenolod */
+    op_data.current_output_plugin = NULL;
+
     for (node = get_input_list(); node; node = g_list_next(node)) {
         ip = INPUT_PLUGIN(node->data);
         if (ip && ip->cleanup) {
@@ -408,8 +415,11 @@
         g_module_close(ip->handle);
     }
 
-    if (ip_data.input_list)
+    if (ip_data.input_list != NULL)
+    {
         g_list_free(ip_data.input_list);
+        ip_data.input_list = NULL;
+    }
 
     for (node = get_output_list(); node; node = g_list_next(node)) {
         op = OUTPUT_PLUGIN(node->data);
@@ -422,8 +432,11 @@
         g_module_close(op->handle);
     }
     
-    if (op_data.output_list)
+    if (op_data.output_list != NULL)
+    {
         g_list_free(op_data.output_list);
+        op_data.output_list = NULL;
+    }
 
     for (node = get_effect_list(); node; node = g_list_next(node)) {
         ep = EFFECT_PLUGIN(node->data);
@@ -436,23 +449,12 @@
         g_module_close(ep->handle);
     }
 
-    if (ep_data.effect_list)
+    if (ep_data.effect_list != NULL)
+    {
         g_list_free(ep_data.effect_list);
-
-#if 0
-    for (node = get_general_enabled_list(); node; node = g_list_next(node)) {
-        gp = GENERAL_PLUGIN(node->data);
-        enable_general_plugin(g_list_index(gp_data.general_list, gp), FALSE);
+        ep_data.effect_list = NULL;
     }
 
-    if (gp_data.enabled_list)
-        g_list_free(gp_data.enabled_list);
-
-    GDK_THREADS_LEAVE();
-    while (g_main_context_iteration(NULL, FALSE));
-    GDK_THREADS_ENTER();
-#endif
-
     for (node = get_general_list(); node; node = g_list_next(node)) {
         gp = GENERAL_PLUGIN(node->data);
         if (gp && gp->cleanup) {
@@ -464,23 +466,12 @@
         g_module_close(gp->handle);
     }
 
-    if (gp_data.general_list)
+    if (gp_data.general_list != NULL)
+    {
         g_list_free(gp_data.general_list);
-
-#if 0
-    for (node = get_vis_enabled_list(); node; node = g_list_next(node)) {
-        vp = VIS_PLUGIN(node->data);
-        enable_vis_plugin(g_list_index(vp_data.vis_list, vp), FALSE);
+        gp_data.general_list = NULL;
     }
 
-    if (vp_data.enabled_list)
-        g_list_free(vp_data.enabled_list);
-
-    GDK_THREADS_LEAVE();
-    while (g_main_context_iteration(NULL, FALSE));
-    GDK_THREADS_ENTER();
-#endif
-
     for (node = get_vis_list(); node; node = g_list_next(node)) {
         vp = VIS_PLUGIN(node->data);
         if (vp && vp->cleanup) {
@@ -492,8 +483,11 @@
         g_module_close(vp->handle);
     }
 
-    if (vp_data.vis_list)
+    if (vp_data.vis_list != NULL)
+    {
         g_list_free(vp_data.vis_list);
+        vp_data.vis_list = NULL;
+    }
 
     for (node = lowlevel_list; node; node = g_list_next(node)) {
         lp = LOWLEVEL_PLUGIN(node->data);
@@ -506,6 +500,16 @@
         g_module_close(lp->handle);
     }
 
-    if (lowlevel_list)
+    if (lowlevel_list != NULL)
+    {
         g_list_free(lowlevel_list);
+        lowlevel_list = NULL;
+    }
+
+    /* XXX: vfs will crash otherwise. -nenolod */
+    if (vfs_transports != NULL)
+    {
+        g_list_free(vfs_transports);
+        vfs_transports = NULL;
+    }
 }