Mercurial > audlegacy
annotate src/audacious/pluginenum.c @ 2799:febdfe7a482b trunk
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
| author | nenolod |
|---|---|
| date | Thu, 24 May 2007 03:41:13 -0700 |
| parents | 7144a4e5e978 |
| children | 8ab12f092722 |
| rev | line source |
|---|---|
| 2313 | 1 /* Audacious - Cross-platform multimedia player |
| 2 * Copyright (C) 2005-2007 Audacious development team | |
| 3 * | |
| 4 * Based on BMP: | |
| 5 * Copyright (C) 2003-2004 BMP development team | |
| 6 * | |
| 7 * Based on XMMS: | |
| 8 * Copyright (C) 1998-2003 XMMS development team | |
| 9 * | |
| 10 * This program is free software; you can redistribute it and/or modify | |
| 11 * it under the terms of the GNU General Public License as published by | |
| 12 * the Free Software Foundation; under version 2 of the License. | |
| 13 * | |
| 14 * This program is distributed in the hope that it will be useful, | |
| 15 * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
| 17 * GNU General Public License for more details. | |
| 18 * | |
| 19 * You should have received a copy of the GNU General Public License | |
| 20 * along with this program; if not, write to the Free Software | |
| 21 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. | |
| 22 */ | |
| 23 | |
| 24 #ifdef HAVE_CONFIG_H | |
| 25 # include "config.h" | |
| 26 #endif | |
| 27 | |
| 28 #ifndef SHARED_SUFFIX | |
| 29 # define SHARED_SUFFIX G_MODULE_SUFFIX | |
| 30 #endif | |
| 31 | |
| 32 #include "pluginenum.h" | |
| 33 | |
| 34 #include <glib.h> | |
| 35 #include <gmodule.h> | |
| 36 #include <glib/gprintf.h> | |
| 37 #include <string.h> | |
| 38 | |
| 39 #include "main.h" | |
| 40 #include "ui_main.h" | |
| 41 #include "playback.h" | |
| 42 #include "playlist.h" | |
|
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2313
diff
changeset
|
43 #include "strings.h" |
| 2313 | 44 #include "util.h" |
| 45 | |
| 46 #include "effect.h" | |
| 47 #include "general.h" | |
| 48 #include "input.h" | |
| 49 #include "output.h" | |
| 50 #include "visualization.h" | |
| 51 | |
| 52 const gchar *plugin_dir_list[] = { | |
| 53 PLUGINSUBS, | |
| 54 NULL | |
| 55 }; | |
| 56 | |
| 57 GHashTable *plugin_matrix = NULL; | |
| 58 GList *lowlevel_list = NULL; | |
| 59 | |
| 2623 | 60 extern GList *vfs_transports; |
| 61 | |
| 2313 | 62 static gint |
| 63 inputlist_compare_func(gconstpointer a, gconstpointer b) | |
| 64 { | |
| 65 const InputPlugin *ap = a, *bp = b; | |
| 66 return strcasecmp(ap->description, bp->description); | |
| 67 } | |
| 68 | |
| 69 static gint | |
| 70 outputlist_compare_func(gconstpointer a, gconstpointer b) | |
| 71 { | |
| 72 const OutputPlugin *ap = a, *bp = b; | |
| 73 return strcasecmp(ap->description, bp->description); | |
| 74 } | |
| 75 | |
| 76 static gint | |
| 77 effectlist_compare_func(gconstpointer a, gconstpointer b) | |
| 78 { | |
| 79 const EffectPlugin *ap = a, *bp = b; | |
| 80 return strcasecmp(ap->description, bp->description); | |
| 81 } | |
| 82 | |
| 83 static gint | |
| 84 generallist_compare_func(gconstpointer a, gconstpointer b) | |
| 85 { | |
| 86 const GeneralPlugin *ap = a, *bp = b; | |
| 87 return strcasecmp(ap->description, bp->description); | |
| 88 } | |
| 89 | |
| 90 static gint | |
| 91 vislist_compare_func(gconstpointer a, gconstpointer b) | |
| 92 { | |
| 93 const VisPlugin *ap = a, *bp = b; | |
| 94 return strcasecmp(ap->description, bp->description); | |
| 95 } | |
| 96 | |
| 97 static gboolean | |
| 98 plugin_is_duplicate(const gchar * filename) | |
| 99 { | |
| 100 GList *l; | |
| 101 const gchar *basename = g_basename(filename); | |
| 102 | |
| 103 /* FIXME: messy stuff */ | |
| 104 | |
| 105 for (l = ip_data.input_list; l; l = g_list_next(l)) | |
| 106 if (!strcmp(basename, g_basename(INPUT_PLUGIN(l->data)->filename))) | |
| 107 return TRUE; | |
| 108 | |
| 109 for (l = op_data.output_list; l; l = g_list_next(l)) | |
| 110 if (!strcmp(basename, g_basename(OUTPUT_PLUGIN(l->data)->filename))) | |
| 111 return TRUE; | |
| 112 | |
| 113 for (l = ep_data.effect_list; l; l = g_list_next(l)) | |
| 114 if (!strcmp(basename, g_basename(EFFECT_PLUGIN(l->data)->filename))) | |
| 115 return TRUE; | |
| 116 | |
| 117 for (l = gp_data.general_list; l; l = g_list_next(l)) | |
| 118 if (!strcmp(basename, g_basename(GENERAL_PLUGIN(l->data)->filename))) | |
| 119 return TRUE; | |
| 120 | |
| 121 for (l = vp_data.vis_list; l; l = g_list_next(l)) | |
| 122 if (!strcmp(basename, g_basename(VIS_PLUGIN(l->data)->filename))) | |
| 123 return TRUE; | |
| 124 | |
| 125 for (l = lowlevel_list; l; l = g_list_next(l)) | |
| 126 if (!strcmp(basename, g_basename(VIS_PLUGIN(l->data)->filename))) | |
| 127 return TRUE; | |
| 128 | |
| 129 return FALSE; | |
| 130 } | |
| 131 | |
| 132 | |
| 133 #define PLUGIN_GET_INFO(x) ((PluginGetInfoFunc)(x))() | |
| 134 typedef Plugin * (*PluginGetInfoFunc) (void); | |
| 135 | |
| 136 static void | |
| 137 input_plugin_init(Plugin * plugin) | |
| 138 { | |
| 139 InputPlugin *p = INPUT_PLUGIN(plugin); | |
| 140 | |
| 141 p->get_vis_type = input_get_vis_type; | |
| 142 p->add_vis_pcm = input_add_vis_pcm; | |
| 143 | |
| 144 /* Pretty const casts courtesy of XMMS's plugin.h legacy. Anyone | |
| 145 else thinks we could use a CONST macro to solve the warnings? | |
| 146 - descender */ | |
| 147 p->set_info = (void (*)(gchar *, gint, gint, gint, gint)) playlist_set_info_old_abi; | |
| 148 p->set_info_text = (void (*)(gchar *)) input_set_info_text; | |
| 149 p->set_status_buffering = (void (*)(gboolean)) input_set_status_buffering; | |
| 150 | |
| 151 ip_data.input_list = g_list_append(ip_data.input_list, p); | |
| 152 | |
| 153 g_hash_table_replace(plugin_matrix, g_path_get_basename(p->filename), | |
| 154 GINT_TO_POINTER(1)); | |
| 155 } | |
| 156 | |
| 157 static void | |
| 158 output_plugin_init(Plugin * plugin) | |
| 159 { | |
| 160 OutputPlugin *p = OUTPUT_PLUGIN(plugin); | |
| 161 op_data.output_list = g_list_append(op_data.output_list, p); | |
| 162 } | |
| 163 | |
| 164 static void | |
| 165 effect_plugin_init(Plugin * plugin) | |
| 166 { | |
| 167 EffectPlugin *p = EFFECT_PLUGIN(plugin); | |
| 168 ep_data.effect_list = g_list_append(ep_data.effect_list, p); | |
| 169 } | |
| 170 | |
| 171 static void | |
| 172 general_plugin_init(Plugin * plugin) | |
| 173 { | |
| 174 GeneralPlugin *p = GENERAL_PLUGIN(plugin); | |
| 175 gp_data.general_list = g_list_append(gp_data.general_list, p); | |
| 176 } | |
| 177 | |
| 178 static void | |
| 179 vis_plugin_init(Plugin * plugin) | |
| 180 { | |
| 181 VisPlugin *p = VIS_PLUGIN(plugin); | |
| 182 p->disable_plugin = vis_disable_plugin; | |
| 183 vp_data.vis_list = g_list_append(vp_data.vis_list, p); | |
| 184 } | |
| 185 | |
| 186 static void | |
| 187 lowlevel_plugin_init(Plugin * plugin) | |
| 188 { | |
| 189 LowlevelPlugin *p = LOWLEVEL_PLUGIN(plugin); | |
| 190 lowlevel_list = g_list_append(lowlevel_list, p); | |
| 191 } | |
| 192 | |
|
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
193 /*******************************************************************/ |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
194 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
195 static void |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
196 plugin2_dispose(GModule *module, const gchar *str, ...) |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
197 { |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
198 gchar buf[4096]; |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
199 va_list va; |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
200 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
201 va_start(va, str); |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
202 vsnprintf(buf, 4096, str, va); |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
203 va_end(va); |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
204 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
205 g_print("*** %s\n", buf); |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
206 g_module_close(module); |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
207 } |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
208 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
209 void |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
210 plugin2_process(PluginHeader *header, GModule *module, const gchar *filename) |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
211 { |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
212 InputPlugin **ip_iter; |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
213 OutputPlugin **op_iter; |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
214 EffectPlugin **ep_iter; |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
215 GeneralPlugin **gp_iter; |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
216 VisPlugin **vp_iter; |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
217 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
218 if (header->magic != PLUGIN_MAGIC) |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
219 return plugin2_dispose(module, "plugin <%s> discarded, invalid module magic", filename); |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
220 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
221 if (header->api_version != __AUDACIOUS_PLUGIN_API__) |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
222 return plugin2_dispose(module, "plugin <%s> discarded, wanting API version %d, we implement API version %d", |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
223 filename, header->api_version, __AUDACIOUS_PLUGIN_API__); |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
224 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
225 if (header->init) |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
226 header->init(); |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
227 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
228 header->priv_assoc = g_new0(Plugin, 1); |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
229 header->priv_assoc->handle = module; |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
230 header->priv_assoc->filename = g_strdup(filename); |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
231 |
|
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
232 if (header->ip_list) |
|
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
233 { |
|
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
234 for (ip_iter = header->ip_list; *ip_iter != NULL; ip_iter++) |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
235 { |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
236 PLUGIN(*ip_iter)->filename = g_strdup(filename); |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
237 g_print("plugin2 '%s' provides InputPlugin <%p>\n", filename, *ip_iter); |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
238 input_plugin_init(PLUGIN(*ip_iter)); |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
239 } |
|
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
240 } |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
241 |
|
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
242 if (header->op_list) |
|
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
243 { |
|
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
244 for (op_iter = header->op_list; *op_iter != NULL; op_iter++) |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
245 { |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
246 g_print("plugin2 '%s' provides OutputPlugin <%p>\n", filename, *op_iter); |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
247 output_plugin_init(PLUGIN(*op_iter)); |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
248 } |
|
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
249 } |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
250 |
|
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
251 if (header->ep_list) |
|
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
252 { |
|
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
253 for (ep_iter = header->ep_list; *ep_iter != NULL; ep_iter++) |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
254 { |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
255 g_print("plugin2 '%s' provides EffectPlugin <%p>\n", filename, *ep_iter); |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
256 effect_plugin_init(PLUGIN(*ep_iter)); |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
257 } |
|
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
258 } |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
259 |
|
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
260 if (header->gp_list) |
|
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
261 { |
|
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
262 for (gp_iter = header->gp_list; *gp_iter != NULL; gp_iter++) |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
263 { |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
264 g_print("plugin2 '%s' provides GeneralPlugin <%p>\n", filename, *gp_iter); |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
265 general_plugin_init(PLUGIN(*gp_iter)); |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
266 } |
|
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
267 } |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
268 |
|
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
269 if (header->vp_list) |
|
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
270 { |
|
2799
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
271 for (vp_iter = header->vp_list; *vp_iter != NULL; vp_iter++) |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
272 { |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
273 g_print("plugin2 '%s' provides VisPlugin <%p>\n", filename, *vp_iter); |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
274 vis_plugin_init(PLUGIN(*vp_iter)); |
|
febdfe7a482b
[svn] - improve plugin2 loader's robustness (e.g. make it not crash)
nenolod
parents:
2798
diff
changeset
|
275 } |
|
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
276 } |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
277 } |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
278 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
279 void |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
280 plugin2_unload(PluginHeader *header) |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
281 { |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
282 GModule *module; |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
283 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
284 g_return_if_fail(header->priv_assoc != NULL); |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
285 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
286 module = header->priv_assoc->handle; |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
287 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
288 g_free(header->priv_assoc->filename); |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
289 g_free(header->priv_assoc); |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
290 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
291 if (header->fini) |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
292 header->fini(); |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
293 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
294 g_module_close(module); |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
295 } |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
296 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
297 /******************************************************************/ |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
298 |
| 2313 | 299 /* FIXME: Placed here (hopefully) temporarily - descender */ |
| 300 | |
| 301 typedef struct { | |
| 302 const gchar *name; | |
| 303 const gchar *id; | |
| 304 void (*init)(Plugin *); | |
| 305 } PluginType; | |
| 306 | |
| 307 static PluginType plugin_types[] = { | |
| 308 { "input" , "get_iplugin_info", input_plugin_init }, | |
| 309 { "output" , "get_oplugin_info", output_plugin_init }, | |
| 310 { "effect" , "get_eplugin_info", effect_plugin_init }, | |
| 311 { "general" , "get_gplugin_info", general_plugin_init }, | |
| 312 { "visualization", "get_vplugin_info", vis_plugin_init }, | |
| 313 { "lowlevel" , "get_lplugin_info", lowlevel_plugin_init }, | |
| 314 { NULL, NULL, NULL } | |
| 315 }; | |
| 316 | |
| 317 static void | |
| 318 add_plugin(const gchar * filename) | |
| 319 { | |
| 320 PluginType *type; | |
| 321 GModule *module; | |
| 322 gpointer func; | |
| 323 | |
| 324 if (plugin_is_duplicate(filename)) | |
| 325 return; | |
| 326 | |
| 2623 | 327 g_message("Loaded plugin (%s)", filename); |
| 328 | |
| 2313 | 329 if (!(module = g_module_open(filename, G_MODULE_BIND_LOCAL))) { |
| 330 printf("Failed to load plugin (%s): %s\n", | |
| 331 filename, g_module_error()); | |
| 332 return; | |
| 333 } | |
| 334 | |
|
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
335 /* v2 plugin loading */ |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
336 if (g_module_symbol(module, "get_plugin_info", &func)) |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
337 { |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
338 PluginHeader *(*header_func_p)() = func; |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
339 PluginHeader *header; |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
340 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
341 /* this should never happen. */ |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
342 g_return_if_fail((header = header_func_p()) != NULL); |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
343 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
344 plugin2_process(header, module, filename); |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
345 return; |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
346 } |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
347 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
348 /* v1 plugin loading */ |
| 2313 | 349 for (type = plugin_types; type->name; type++) |
| 350 { | |
| 351 if (g_module_symbol(module, type->id, &func)) { | |
| 352 Plugin *plugin = PLUGIN_GET_INFO(func); | |
| 353 | |
| 354 plugin->handle = module; | |
| 355 plugin->filename = g_strdup(filename); | |
| 356 type->init(PLUGIN_GET_INFO(func)); | |
| 357 | |
| 358 return; | |
| 359 } | |
| 360 } | |
| 361 | |
| 362 printf("Invalid plugin (%s)\n", filename); | |
| 363 g_module_close(module); | |
| 364 } | |
| 365 | |
| 366 static gboolean | |
| 367 scan_plugin_func(const gchar * path, const gchar * basename, gpointer data) | |
| 368 { | |
| 369 if (!str_has_suffix_nocase(basename, SHARED_SUFFIX)) | |
| 370 return FALSE; | |
| 371 | |
| 372 if (!g_file_test(path, G_FILE_TEST_IS_REGULAR)) | |
| 373 return FALSE; | |
| 374 | |
| 375 add_plugin(path); | |
| 376 | |
| 377 return FALSE; | |
| 378 } | |
| 379 | |
| 380 static void | |
| 381 scan_plugins(const gchar * path) | |
| 382 { | |
| 383 dir_foreach(path, scan_plugin_func, NULL, NULL); | |
| 384 } | |
| 385 | |
| 386 void | |
| 387 plugin_system_init(void) | |
| 388 { | |
| 389 gchar *dir, **disabled; | |
| 390 GList *node; | |
| 391 OutputPlugin *op; | |
| 392 InputPlugin *ip; | |
| 393 LowlevelPlugin *lp; | |
| 394 gint dirsel = 0, i = 0; | |
| 395 | |
| 396 if (!g_module_supported()) { | |
| 397 report_error("Module loading not supported! Plugins will not be loaded.\n"); | |
| 398 return; | |
| 399 } | |
| 400 | |
|
2624
840fb578a834
[svn] - [security, backport to 1.3] fix improper comparisons of hashtables used by the plugin loader.
nenolod
parents:
2623
diff
changeset
|
401 plugin_matrix = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
| 2313 | 402 NULL); |
| 403 | |
| 404 #ifndef DISABLE_USER_PLUGIN_DIR | |
| 405 scan_plugins(bmp_paths[BMP_PATH_USER_PLUGIN_DIR]); | |
| 406 /* | |
| 407 * This is in a separate loop so if the user puts them in the | |
| 408 * wrong dir we'll still get them in the right order (home dir | |
| 409 * first) - Zinx | |
| 410 */ | |
| 411 while (plugin_dir_list[dirsel]) { | |
| 412 dir = g_build_filename(bmp_paths[BMP_PATH_USER_PLUGIN_DIR], | |
| 413 plugin_dir_list[dirsel++], NULL); | |
| 414 scan_plugins(dir); | |
| 415 g_free(dir); | |
| 416 } | |
| 417 dirsel = 0; | |
| 418 #endif | |
| 419 | |
| 420 while (plugin_dir_list[dirsel]) { | |
| 421 dir = g_build_filename(PLUGIN_DIR, plugin_dir_list[dirsel++], NULL); | |
| 422 scan_plugins(dir); | |
| 423 g_free(dir); | |
| 424 } | |
| 425 | |
| 426 op_data.output_list = g_list_sort(op_data.output_list, outputlist_compare_func); | |
| 427 if (!op_data.current_output_plugin | |
| 428 && g_list_length(op_data.output_list)) { | |
| 429 op_data.current_output_plugin = op_data.output_list->data; | |
| 430 } | |
| 431 | |
| 432 ip_data.input_list = g_list_sort(ip_data.input_list, inputlist_compare_func); | |
| 433 | |
| 434 ep_data.effect_list = g_list_sort(ep_data.effect_list, effectlist_compare_func); | |
| 435 ep_data.enabled_list = NULL; | |
| 436 | |
| 437 gp_data.general_list = g_list_sort(gp_data.general_list, generallist_compare_func); | |
| 438 gp_data.enabled_list = NULL; | |
| 439 | |
| 440 vp_data.vis_list = g_list_sort(vp_data.vis_list, vislist_compare_func); | |
| 441 vp_data.enabled_list = NULL; | |
| 442 | |
| 443 general_enable_from_stringified_list(cfg.enabled_gplugins); | |
| 444 vis_enable_from_stringified_list(cfg.enabled_vplugins); | |
| 445 effect_enable_from_stringified_list(cfg.enabled_eplugins); | |
| 446 | |
| 447 g_free(cfg.enabled_gplugins); | |
| 448 cfg.enabled_gplugins = NULL; | |
| 449 | |
| 450 g_free(cfg.enabled_vplugins); | |
| 451 cfg.enabled_vplugins = NULL; | |
| 452 | |
| 453 g_free(cfg.enabled_eplugins); | |
| 454 cfg.enabled_eplugins = NULL; | |
| 455 | |
| 456 for (node = op_data.output_list; node; node = g_list_next(node)) { | |
| 457 op = OUTPUT_PLUGIN(node->data); | |
| 458 /* | |
| 459 * Only test basename to avoid problems when changing | |
| 460 * prefix. We will only see one plugin with the same | |
| 461 * basename, so this is usually what the user want. | |
| 462 */ | |
| 463 if (!strcmp(g_basename(cfg.outputplugin), g_basename(op->filename))) | |
| 464 op_data.current_output_plugin = op; | |
| 465 if (op->init) | |
| 466 op->init(); | |
| 467 } | |
| 468 | |
| 469 for (node = ip_data.input_list; node; node = g_list_next(node)) { | |
| 470 ip = INPUT_PLUGIN(node->data); | |
| 471 if (ip->init) | |
| 472 ip->init(); | |
| 473 } | |
| 474 | |
| 475 for (node = lowlevel_list; node; node = g_list_next(node)) { | |
| 476 lp = LOWLEVEL_PLUGIN(node->data); | |
| 477 if (lp->init) | |
| 478 lp->init(); | |
| 479 } | |
| 480 | |
| 481 if (cfg.disabled_iplugins) { | |
| 482 disabled = g_strsplit(cfg.disabled_iplugins, ":", 0); | |
| 483 while (disabled[i]) { | |
| 484 g_hash_table_replace(plugin_matrix, disabled[i], | |
| 485 GINT_TO_POINTER(FALSE)); | |
| 486 i++; | |
| 487 } | |
| 488 | |
| 489 g_free(disabled); | |
| 490 | |
| 491 g_free(cfg.disabled_iplugins); | |
| 492 cfg.disabled_iplugins = NULL; | |
| 493 } | |
| 494 } | |
| 495 | |
| 496 void | |
| 497 plugin_system_cleanup(void) | |
| 498 { | |
| 499 InputPlugin *ip; | |
| 500 OutputPlugin *op; | |
| 501 EffectPlugin *ep; | |
| 502 GeneralPlugin *gp; | |
| 503 VisPlugin *vp; | |
| 504 LowlevelPlugin *lp; | |
| 505 GList *node; | |
| 506 | |
| 507 g_message("Shutting down plugin system"); | |
| 508 | |
| 509 if (playback_get_playing()) { | |
| 510 ip_data.stop = TRUE; | |
| 511 playback_stop(); | |
| 512 ip_data.stop = FALSE; | |
| 513 } | |
| 514 | |
| 2623 | 515 /* FIXME: race condition -nenolod */ |
| 516 op_data.current_output_plugin = NULL; | |
| 517 | |
| 2313 | 518 for (node = get_input_list(); node; node = g_list_next(node)) { |
| 519 ip = INPUT_PLUGIN(node->data); | |
| 520 if (ip && ip->cleanup) { | |
| 521 ip->cleanup(); | |
| 522 GDK_THREADS_LEAVE(); | |
| 523 while (g_main_context_iteration(NULL, FALSE)); | |
| 524 GDK_THREADS_ENTER(); | |
| 525 } | |
|
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
526 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
527 if (ip->handle) |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
528 g_module_close(ip->handle); |
| 2313 | 529 } |
| 530 | |
| 2623 | 531 if (ip_data.input_list != NULL) |
| 532 { | |
| 2313 | 533 g_list_free(ip_data.input_list); |
| 2623 | 534 ip_data.input_list = NULL; |
| 535 } | |
| 2313 | 536 |
| 537 for (node = get_output_list(); node; node = g_list_next(node)) { | |
| 538 op = OUTPUT_PLUGIN(node->data); | |
| 539 if (op && op->cleanup) { | |
| 540 op->cleanup(); | |
| 541 GDK_THREADS_LEAVE(); | |
| 542 while (g_main_context_iteration(NULL, FALSE)); | |
| 543 GDK_THREADS_ENTER(); | |
| 544 } | |
|
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
545 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
546 if (op->handle) |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
547 g_module_close(op->handle); |
| 2313 | 548 } |
| 549 | |
| 2623 | 550 if (op_data.output_list != NULL) |
| 551 { | |
| 2313 | 552 g_list_free(op_data.output_list); |
| 2623 | 553 op_data.output_list = NULL; |
| 554 } | |
| 2313 | 555 |
| 556 for (node = get_effect_list(); node; node = g_list_next(node)) { | |
| 557 ep = EFFECT_PLUGIN(node->data); | |
| 558 if (ep && ep->cleanup) { | |
| 559 ep->cleanup(); | |
| 560 GDK_THREADS_LEAVE(); | |
| 561 while (g_main_context_iteration(NULL, FALSE)); | |
| 562 GDK_THREADS_ENTER(); | |
| 563 } | |
|
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
564 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
565 if (ep->handle) |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
566 g_module_close(ep->handle); |
| 2313 | 567 } |
| 568 | |
| 2623 | 569 if (ep_data.effect_list != NULL) |
| 570 { | |
| 2313 | 571 g_list_free(ep_data.effect_list); |
| 2623 | 572 ep_data.effect_list = NULL; |
| 2313 | 573 } |
| 574 | |
| 575 for (node = get_general_list(); node; node = g_list_next(node)) { | |
| 576 gp = GENERAL_PLUGIN(node->data); | |
| 577 if (gp && gp->cleanup) { | |
| 578 gp->cleanup(); | |
| 579 GDK_THREADS_LEAVE(); | |
| 580 while (g_main_context_iteration(NULL, FALSE)); | |
| 581 GDK_THREADS_ENTER(); | |
| 582 } | |
|
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
583 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
584 if (gp->handle) |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
585 g_module_close(gp->handle); |
| 2313 | 586 } |
| 587 | |
| 2623 | 588 if (gp_data.general_list != NULL) |
| 589 { | |
| 2313 | 590 g_list_free(gp_data.general_list); |
| 2623 | 591 gp_data.general_list = NULL; |
| 2313 | 592 } |
| 593 | |
| 594 for (node = get_vis_list(); node; node = g_list_next(node)) { | |
| 595 vp = VIS_PLUGIN(node->data); | |
| 596 if (vp && vp->cleanup) { | |
| 597 vp->cleanup(); | |
| 598 GDK_THREADS_LEAVE(); | |
| 599 while (g_main_context_iteration(NULL, FALSE)); | |
| 600 GDK_THREADS_ENTER(); | |
| 601 } | |
|
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
602 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
603 if (vp->handle) |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
604 g_module_close(vp->handle); |
| 2313 | 605 } |
| 606 | |
| 2623 | 607 if (vp_data.vis_list != NULL) |
| 608 { | |
| 2313 | 609 g_list_free(vp_data.vis_list); |
| 2623 | 610 vp_data.vis_list = NULL; |
| 611 } | |
| 2313 | 612 |
| 613 for (node = lowlevel_list; node; node = g_list_next(node)) { | |
| 614 lp = LOWLEVEL_PLUGIN(node->data); | |
| 615 if (lp && lp->cleanup) { | |
| 616 lp->cleanup(); | |
| 617 GDK_THREADS_LEAVE(); | |
| 618 while (g_main_context_iteration(NULL, FALSE)); | |
| 619 GDK_THREADS_ENTER(); | |
| 620 } | |
|
2797
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
621 |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
622 if (lp->handle) |
|
f0c1c8b22c88
[svn] - first attempt at an plugin API2 loader. this is entirely implemented inside the plugin2 namespace, so please respect that if you go editing this ;p
nenolod
parents:
2795
diff
changeset
|
623 g_module_close(lp->handle); |
| 2313 | 624 } |
| 625 | |
| 2623 | 626 if (lowlevel_list != NULL) |
| 627 { | |
| 2313 | 628 g_list_free(lowlevel_list); |
| 2623 | 629 lowlevel_list = NULL; |
| 630 } | |
| 631 | |
| 632 /* XXX: vfs will crash otherwise. -nenolod */ | |
| 633 if (vfs_transports != NULL) | |
| 634 { | |
| 635 g_list_free(vfs_transports); | |
| 636 vfs_transports = NULL; | |
| 637 } | |
|
2682
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2624
diff
changeset
|
638 |
|
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2624
diff
changeset
|
639 g_hash_table_destroy( plugin_matrix ); |
| 2313 | 640 } |
