Mercurial > audlegacy
annotate src/audacious/pluginenum.c @ 2733:cf080b11c3fa trunk
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
| author | magma |
|---|---|
| date | Fri, 11 May 2007 11:52:56 -0700 |
| parents | c35913222440 |
| children | 637359219e10 |
| 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 | |
|
2711
c35913222440
[svn] Initial commit of dbus client library for plugins. Various changes were made to the plugin structure to support dbus.
magma
parents:
2709
diff
changeset
|
39 |
|
c35913222440
[svn] Initial commit of dbus client library for plugins. Various changes were made to the plugin structure to support dbus.
magma
parents:
2709
diff
changeset
|
40 #ifdef USE_DBUS |
|
2733
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
41 #include "dbus.h" |
|
2711
c35913222440
[svn] Initial commit of dbus client library for plugins. Various changes were made to the plugin structure to support dbus.
magma
parents:
2709
diff
changeset
|
42 #include "dbus-service.h" |
|
c35913222440
[svn] Initial commit of dbus client library for plugins. Various changes were made to the plugin structure to support dbus.
magma
parents:
2709
diff
changeset
|
43 #endif |
|
c35913222440
[svn] Initial commit of dbus client library for plugins. Various changes were made to the plugin structure to support dbus.
magma
parents:
2709
diff
changeset
|
44 |
| 2313 | 45 #include "main.h" |
| 46 #include "ui_main.h" | |
| 47 #include "playback.h" | |
| 48 #include "playlist.h" | |
|
2373
ad1d7687814c
[svn] made strings.h for existing strings.c, cleanups
mf0102
parents:
2313
diff
changeset
|
49 #include "strings.h" |
| 2313 | 50 #include "util.h" |
| 51 | |
| 52 #include "effect.h" | |
| 53 #include "general.h" | |
| 54 #include "input.h" | |
| 55 #include "output.h" | |
| 56 #include "visualization.h" | |
| 57 | |
| 58 const gchar *plugin_dir_list[] = { | |
| 59 PLUGINSUBS, | |
| 60 NULL | |
| 61 }; | |
| 62 | |
| 63 GHashTable *plugin_matrix = NULL; | |
| 64 GList *lowlevel_list = NULL; | |
| 65 | |
|
2733
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
66 #ifdef USE_DBUS |
|
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
67 static DBusGProxy *dbus_proxy = NULL; |
|
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
68 static DBusGConnection *connection = NULL; |
|
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
69 #endif |
|
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
70 |
| 2623 | 71 extern GList *vfs_transports; |
| 72 | |
| 2313 | 73 static gint |
| 74 inputlist_compare_func(gconstpointer a, gconstpointer b) | |
| 75 { | |
| 76 const InputPlugin *ap = a, *bp = b; | |
| 77 return strcasecmp(ap->description, bp->description); | |
| 78 } | |
| 79 | |
| 80 static gint | |
| 81 outputlist_compare_func(gconstpointer a, gconstpointer b) | |
| 82 { | |
| 83 const OutputPlugin *ap = a, *bp = b; | |
| 84 return strcasecmp(ap->description, bp->description); | |
| 85 } | |
| 86 | |
| 87 static gint | |
| 88 effectlist_compare_func(gconstpointer a, gconstpointer b) | |
| 89 { | |
| 90 const EffectPlugin *ap = a, *bp = b; | |
| 91 return strcasecmp(ap->description, bp->description); | |
| 92 } | |
| 93 | |
| 94 static gint | |
| 95 generallist_compare_func(gconstpointer a, gconstpointer b) | |
| 96 { | |
| 97 const GeneralPlugin *ap = a, *bp = b; | |
| 98 return strcasecmp(ap->description, bp->description); | |
| 99 } | |
| 100 | |
| 101 static gint | |
| 102 vislist_compare_func(gconstpointer a, gconstpointer b) | |
| 103 { | |
| 104 const VisPlugin *ap = a, *bp = b; | |
| 105 return strcasecmp(ap->description, bp->description); | |
| 106 } | |
| 107 | |
| 108 static gboolean | |
| 109 plugin_is_duplicate(const gchar * filename) | |
| 110 { | |
| 111 GList *l; | |
| 112 const gchar *basename = g_basename(filename); | |
| 113 | |
| 114 /* FIXME: messy stuff */ | |
| 115 | |
| 116 for (l = ip_data.input_list; l; l = g_list_next(l)) | |
| 117 if (!strcmp(basename, g_basename(INPUT_PLUGIN(l->data)->filename))) | |
| 118 return TRUE; | |
| 119 | |
| 120 for (l = op_data.output_list; l; l = g_list_next(l)) | |
| 121 if (!strcmp(basename, g_basename(OUTPUT_PLUGIN(l->data)->filename))) | |
| 122 return TRUE; | |
| 123 | |
| 124 for (l = ep_data.effect_list; l; l = g_list_next(l)) | |
| 125 if (!strcmp(basename, g_basename(EFFECT_PLUGIN(l->data)->filename))) | |
| 126 return TRUE; | |
| 127 | |
| 128 for (l = gp_data.general_list; l; l = g_list_next(l)) | |
| 129 if (!strcmp(basename, g_basename(GENERAL_PLUGIN(l->data)->filename))) | |
| 130 return TRUE; | |
| 131 | |
| 132 for (l = vp_data.vis_list; l; l = g_list_next(l)) | |
| 133 if (!strcmp(basename, g_basename(VIS_PLUGIN(l->data)->filename))) | |
| 134 return TRUE; | |
| 135 | |
| 136 for (l = lowlevel_list; l; l = g_list_next(l)) | |
| 137 if (!strcmp(basename, g_basename(VIS_PLUGIN(l->data)->filename))) | |
| 138 return TRUE; | |
| 139 | |
| 140 return FALSE; | |
| 141 } | |
| 142 | |
| 143 | |
| 144 #define PLUGIN_GET_INFO(x) ((PluginGetInfoFunc)(x))() | |
| 145 typedef Plugin * (*PluginGetInfoFunc) (void); | |
| 146 | |
| 147 static void | |
| 148 input_plugin_init(Plugin * plugin) | |
| 149 { | |
| 150 InputPlugin *p = INPUT_PLUGIN(plugin); | |
| 151 | |
| 152 p->get_vis_type = input_get_vis_type; | |
| 153 p->add_vis_pcm = input_add_vis_pcm; | |
| 154 | |
| 155 /* Pretty const casts courtesy of XMMS's plugin.h legacy. Anyone | |
| 156 else thinks we could use a CONST macro to solve the warnings? | |
| 157 - descender */ | |
| 158 p->set_info = (void (*)(gchar *, gint, gint, gint, gint)) playlist_set_info_old_abi; | |
| 159 p->set_info_text = (void (*)(gchar *)) input_set_info_text; | |
| 160 p->set_status_buffering = (void (*)(gboolean)) input_set_status_buffering; | |
| 161 | |
| 162 ip_data.input_list = g_list_append(ip_data.input_list, p); | |
| 163 | |
| 164 g_hash_table_replace(plugin_matrix, g_path_get_basename(p->filename), | |
| 165 GINT_TO_POINTER(1)); | |
| 166 } | |
| 167 | |
| 168 static void | |
| 169 output_plugin_init(Plugin * plugin) | |
| 170 { | |
| 171 OutputPlugin *p = OUTPUT_PLUGIN(plugin); | |
| 172 op_data.output_list = g_list_append(op_data.output_list, p); | |
| 173 } | |
| 174 | |
| 175 static void | |
| 176 effect_plugin_init(Plugin * plugin) | |
| 177 { | |
| 178 EffectPlugin *p = EFFECT_PLUGIN(plugin); | |
| 179 ep_data.effect_list = g_list_append(ep_data.effect_list, p); | |
| 180 } | |
| 181 | |
| 182 static void | |
| 183 general_plugin_init(Plugin * plugin) | |
| 184 { | |
| 185 GeneralPlugin *p = GENERAL_PLUGIN(plugin); | |
|
2709
47ea8eedd428
[svn] - drop controlsocket code. this probably does not compile yet.
nenolod
parents:
2682
diff
changeset
|
186 p->xmms_session = -1; |
|
2711
c35913222440
[svn] Initial commit of dbus client library for plugins. Various changes were made to the plugin structure to support dbus.
magma
parents:
2709
diff
changeset
|
187 #ifdef USE_DBUS |
|
2733
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
188 p->dbus_proxy = dbus_proxy; |
|
2711
c35913222440
[svn] Initial commit of dbus client library for plugins. Various changes were made to the plugin structure to support dbus.
magma
parents:
2709
diff
changeset
|
189 #endif |
| 2313 | 190 gp_data.general_list = g_list_append(gp_data.general_list, p); |
| 191 } | |
| 192 | |
| 193 static void | |
| 194 vis_plugin_init(Plugin * plugin) | |
| 195 { | |
| 196 VisPlugin *p = VIS_PLUGIN(plugin); | |
|
2709
47ea8eedd428
[svn] - drop controlsocket code. this probably does not compile yet.
nenolod
parents:
2682
diff
changeset
|
197 p->xmms_session = -1; |
|
2711
c35913222440
[svn] Initial commit of dbus client library for plugins. Various changes were made to the plugin structure to support dbus.
magma
parents:
2709
diff
changeset
|
198 #ifdef USE_DBUS |
|
2733
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
199 p->dbus_proxy = dbus_proxy; |
|
2711
c35913222440
[svn] Initial commit of dbus client library for plugins. Various changes were made to the plugin structure to support dbus.
magma
parents:
2709
diff
changeset
|
200 #endif |
| 2313 | 201 p->disable_plugin = vis_disable_plugin; |
| 202 vp_data.vis_list = g_list_append(vp_data.vis_list, p); | |
| 203 } | |
| 204 | |
| 205 static void | |
| 206 lowlevel_plugin_init(Plugin * plugin) | |
| 207 { | |
| 208 LowlevelPlugin *p = LOWLEVEL_PLUGIN(plugin); | |
| 209 lowlevel_list = g_list_append(lowlevel_list, p); | |
| 210 } | |
| 211 | |
| 212 /* FIXME: Placed here (hopefully) temporarily - descender */ | |
| 213 | |
| 214 typedef struct { | |
| 215 const gchar *name; | |
| 216 const gchar *id; | |
| 217 void (*init)(Plugin *); | |
| 218 } PluginType; | |
| 219 | |
| 220 static PluginType plugin_types[] = { | |
| 221 { "input" , "get_iplugin_info", input_plugin_init }, | |
| 222 { "output" , "get_oplugin_info", output_plugin_init }, | |
| 223 { "effect" , "get_eplugin_info", effect_plugin_init }, | |
| 224 { "general" , "get_gplugin_info", general_plugin_init }, | |
| 225 { "visualization", "get_vplugin_info", vis_plugin_init }, | |
| 226 { "lowlevel" , "get_lplugin_info", lowlevel_plugin_init }, | |
| 227 { NULL, NULL, NULL } | |
| 228 }; | |
| 229 | |
| 230 static void | |
| 231 add_plugin(const gchar * filename) | |
| 232 { | |
| 233 PluginType *type; | |
| 234 GModule *module; | |
| 235 gpointer func; | |
| 236 | |
| 237 if (plugin_is_duplicate(filename)) | |
| 238 return; | |
| 239 | |
| 2623 | 240 g_message("Loaded plugin (%s)", filename); |
| 241 | |
| 2313 | 242 if (!(module = g_module_open(filename, G_MODULE_BIND_LOCAL))) { |
| 243 printf("Failed to load plugin (%s): %s\n", | |
| 244 filename, g_module_error()); | |
| 245 return; | |
| 246 } | |
| 247 | |
| 248 for (type = plugin_types; type->name; type++) | |
| 249 { | |
| 250 if (g_module_symbol(module, type->id, &func)) { | |
| 251 Plugin *plugin = PLUGIN_GET_INFO(func); | |
| 252 | |
| 253 plugin->handle = module; | |
| 254 plugin->filename = g_strdup(filename); | |
| 255 type->init(PLUGIN_GET_INFO(func)); | |
| 256 | |
| 257 return; | |
| 258 } | |
| 259 } | |
| 260 | |
| 261 printf("Invalid plugin (%s)\n", filename); | |
| 262 g_module_close(module); | |
| 263 } | |
| 264 | |
| 265 static gboolean | |
| 266 scan_plugin_func(const gchar * path, const gchar * basename, gpointer data) | |
| 267 { | |
| 268 if (!str_has_suffix_nocase(basename, SHARED_SUFFIX)) | |
| 269 return FALSE; | |
| 270 | |
| 271 if (!g_file_test(path, G_FILE_TEST_IS_REGULAR)) | |
| 272 return FALSE; | |
| 273 | |
| 274 add_plugin(path); | |
| 275 | |
| 276 return FALSE; | |
| 277 } | |
| 278 | |
| 279 static void | |
| 280 scan_plugins(const gchar * path) | |
| 281 { | |
| 282 dir_foreach(path, scan_plugin_func, NULL, NULL); | |
| 283 } | |
| 284 | |
| 285 void | |
| 286 plugin_system_init(void) | |
| 287 { | |
| 288 gchar *dir, **disabled; | |
| 289 GList *node; | |
| 290 OutputPlugin *op; | |
| 291 InputPlugin *ip; | |
| 292 LowlevelPlugin *lp; | |
| 293 gint dirsel = 0, i = 0; | |
| 294 | |
|
2733
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
295 #ifdef USE_DBUS |
|
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
296 GError *error = NULL; |
|
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
297 connection = dbus_g_bus_get(DBUS_BUS_SESSION, &error); |
|
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
298 |
|
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
299 if (connection == NULL) |
|
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
300 { |
|
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
301 g_printerr("audtool: D-Bus error: %s", error->message); |
|
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
302 g_error_free(error); |
|
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
303 |
|
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
304 exit(EXIT_FAILURE); |
|
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
305 } |
|
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
306 |
|
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
307 dbus_proxy = dbus_g_proxy_new_for_name(connection, AUDACIOUS_DBUS_SERVICE, |
|
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
308 AUDACIOUS_DBUS_PATH, |
|
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
309 AUDACIOUS_DBUS_INTERFACE); |
|
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
310 #endif |
|
cf080b11c3fa
[svn] Implemented more of the stubs in audctrl; Added more methods to objects.xml with implementations in dbus.c. I'm still trying to get plugins working with libaudclient.
magma
parents:
2711
diff
changeset
|
311 |
| 2313 | 312 if (!g_module_supported()) { |
| 313 report_error("Module loading not supported! Plugins will not be loaded.\n"); | |
| 314 return; | |
| 315 } | |
| 316 | |
|
2624
840fb578a834
[svn] - [security, backport to 1.3] fix improper comparisons of hashtables used by the plugin loader.
nenolod
parents:
2623
diff
changeset
|
317 plugin_matrix = g_hash_table_new_full(g_str_hash, g_str_equal, g_free, |
| 2313 | 318 NULL); |
| 319 | |
| 320 #ifndef DISABLE_USER_PLUGIN_DIR | |
| 321 scan_plugins(bmp_paths[BMP_PATH_USER_PLUGIN_DIR]); | |
| 322 /* | |
| 323 * This is in a separate loop so if the user puts them in the | |
| 324 * wrong dir we'll still get them in the right order (home dir | |
| 325 * first) - Zinx | |
| 326 */ | |
| 327 while (plugin_dir_list[dirsel]) { | |
| 328 dir = g_build_filename(bmp_paths[BMP_PATH_USER_PLUGIN_DIR], | |
| 329 plugin_dir_list[dirsel++], NULL); | |
| 330 scan_plugins(dir); | |
| 331 g_free(dir); | |
| 332 } | |
| 333 dirsel = 0; | |
| 334 #endif | |
| 335 | |
| 336 while (plugin_dir_list[dirsel]) { | |
| 337 dir = g_build_filename(PLUGIN_DIR, plugin_dir_list[dirsel++], NULL); | |
| 338 scan_plugins(dir); | |
| 339 g_free(dir); | |
| 340 } | |
| 341 | |
| 342 op_data.output_list = g_list_sort(op_data.output_list, outputlist_compare_func); | |
| 343 if (!op_data.current_output_plugin | |
| 344 && g_list_length(op_data.output_list)) { | |
| 345 op_data.current_output_plugin = op_data.output_list->data; | |
| 346 } | |
| 347 | |
| 348 ip_data.input_list = g_list_sort(ip_data.input_list, inputlist_compare_func); | |
| 349 | |
| 350 ep_data.effect_list = g_list_sort(ep_data.effect_list, effectlist_compare_func); | |
| 351 ep_data.enabled_list = NULL; | |
| 352 | |
| 353 gp_data.general_list = g_list_sort(gp_data.general_list, generallist_compare_func); | |
| 354 gp_data.enabled_list = NULL; | |
| 355 | |
| 356 vp_data.vis_list = g_list_sort(vp_data.vis_list, vislist_compare_func); | |
| 357 vp_data.enabled_list = NULL; | |
| 358 | |
| 359 general_enable_from_stringified_list(cfg.enabled_gplugins); | |
| 360 vis_enable_from_stringified_list(cfg.enabled_vplugins); | |
| 361 effect_enable_from_stringified_list(cfg.enabled_eplugins); | |
| 362 | |
| 363 g_free(cfg.enabled_gplugins); | |
| 364 cfg.enabled_gplugins = NULL; | |
| 365 | |
| 366 g_free(cfg.enabled_vplugins); | |
| 367 cfg.enabled_vplugins = NULL; | |
| 368 | |
| 369 g_free(cfg.enabled_eplugins); | |
| 370 cfg.enabled_eplugins = NULL; | |
| 371 | |
| 372 for (node = op_data.output_list; node; node = g_list_next(node)) { | |
| 373 op = OUTPUT_PLUGIN(node->data); | |
| 374 /* | |
| 375 * Only test basename to avoid problems when changing | |
| 376 * prefix. We will only see one plugin with the same | |
| 377 * basename, so this is usually what the user want. | |
| 378 */ | |
| 379 if (!strcmp(g_basename(cfg.outputplugin), g_basename(op->filename))) | |
| 380 op_data.current_output_plugin = op; | |
| 381 if (op->init) | |
| 382 op->init(); | |
| 383 } | |
| 384 | |
| 385 for (node = ip_data.input_list; node; node = g_list_next(node)) { | |
| 386 ip = INPUT_PLUGIN(node->data); | |
| 387 if (ip->init) | |
| 388 ip->init(); | |
| 389 } | |
| 390 | |
| 391 for (node = lowlevel_list; node; node = g_list_next(node)) { | |
| 392 lp = LOWLEVEL_PLUGIN(node->data); | |
| 393 if (lp->init) | |
| 394 lp->init(); | |
| 395 } | |
| 396 | |
| 397 if (cfg.disabled_iplugins) { | |
| 398 disabled = g_strsplit(cfg.disabled_iplugins, ":", 0); | |
| 399 while (disabled[i]) { | |
| 400 g_hash_table_replace(plugin_matrix, disabled[i], | |
| 401 GINT_TO_POINTER(FALSE)); | |
| 402 i++; | |
| 403 } | |
| 404 | |
| 405 g_free(disabled); | |
| 406 | |
| 407 g_free(cfg.disabled_iplugins); | |
| 408 cfg.disabled_iplugins = NULL; | |
| 409 } | |
| 410 } | |
| 411 | |
| 412 void | |
| 413 plugin_system_cleanup(void) | |
| 414 { | |
| 415 InputPlugin *ip; | |
| 416 OutputPlugin *op; | |
| 417 EffectPlugin *ep; | |
| 418 GeneralPlugin *gp; | |
| 419 VisPlugin *vp; | |
| 420 LowlevelPlugin *lp; | |
| 421 GList *node; | |
| 422 | |
| 423 g_message("Shutting down plugin system"); | |
| 424 | |
| 425 if (playback_get_playing()) { | |
| 426 ip_data.stop = TRUE; | |
| 427 playback_stop(); | |
| 428 ip_data.stop = FALSE; | |
| 429 } | |
| 430 | |
| 2623 | 431 /* FIXME: race condition -nenolod */ |
| 432 op_data.current_output_plugin = NULL; | |
| 433 | |
| 2313 | 434 for (node = get_input_list(); node; node = g_list_next(node)) { |
| 435 ip = INPUT_PLUGIN(node->data); | |
| 436 if (ip && ip->cleanup) { | |
| 437 ip->cleanup(); | |
| 438 GDK_THREADS_LEAVE(); | |
| 439 while (g_main_context_iteration(NULL, FALSE)); | |
| 440 GDK_THREADS_ENTER(); | |
| 441 } | |
| 442 g_module_close(ip->handle); | |
| 443 } | |
| 444 | |
| 2623 | 445 if (ip_data.input_list != NULL) |
| 446 { | |
| 2313 | 447 g_list_free(ip_data.input_list); |
| 2623 | 448 ip_data.input_list = NULL; |
| 449 } | |
| 2313 | 450 |
| 451 for (node = get_output_list(); node; node = g_list_next(node)) { | |
| 452 op = OUTPUT_PLUGIN(node->data); | |
| 453 if (op && op->cleanup) { | |
| 454 op->cleanup(); | |
| 455 GDK_THREADS_LEAVE(); | |
| 456 while (g_main_context_iteration(NULL, FALSE)); | |
| 457 GDK_THREADS_ENTER(); | |
| 458 } | |
| 459 g_module_close(op->handle); | |
| 460 } | |
| 461 | |
| 2623 | 462 if (op_data.output_list != NULL) |
| 463 { | |
| 2313 | 464 g_list_free(op_data.output_list); |
| 2623 | 465 op_data.output_list = NULL; |
| 466 } | |
| 2313 | 467 |
| 468 for (node = get_effect_list(); node; node = g_list_next(node)) { | |
| 469 ep = EFFECT_PLUGIN(node->data); | |
| 470 if (ep && ep->cleanup) { | |
| 471 ep->cleanup(); | |
| 472 GDK_THREADS_LEAVE(); | |
| 473 while (g_main_context_iteration(NULL, FALSE)); | |
| 474 GDK_THREADS_ENTER(); | |
| 475 } | |
| 476 g_module_close(ep->handle); | |
| 477 } | |
| 478 | |
| 2623 | 479 if (ep_data.effect_list != NULL) |
| 480 { | |
| 2313 | 481 g_list_free(ep_data.effect_list); |
| 2623 | 482 ep_data.effect_list = NULL; |
| 2313 | 483 } |
| 484 | |
| 485 for (node = get_general_list(); node; node = g_list_next(node)) { | |
| 486 gp = GENERAL_PLUGIN(node->data); | |
| 487 if (gp && gp->cleanup) { | |
| 488 gp->cleanup(); | |
| 489 GDK_THREADS_LEAVE(); | |
| 490 while (g_main_context_iteration(NULL, FALSE)); | |
| 491 GDK_THREADS_ENTER(); | |
| 492 } | |
| 493 g_module_close(gp->handle); | |
| 494 } | |
| 495 | |
| 2623 | 496 if (gp_data.general_list != NULL) |
| 497 { | |
| 2313 | 498 g_list_free(gp_data.general_list); |
| 2623 | 499 gp_data.general_list = NULL; |
| 2313 | 500 } |
| 501 | |
| 502 for (node = get_vis_list(); node; node = g_list_next(node)) { | |
| 503 vp = VIS_PLUGIN(node->data); | |
| 504 if (vp && vp->cleanup) { | |
| 505 vp->cleanup(); | |
| 506 GDK_THREADS_LEAVE(); | |
| 507 while (g_main_context_iteration(NULL, FALSE)); | |
| 508 GDK_THREADS_ENTER(); | |
| 509 } | |
| 510 g_module_close(vp->handle); | |
| 511 } | |
| 512 | |
| 2623 | 513 if (vp_data.vis_list != NULL) |
| 514 { | |
| 2313 | 515 g_list_free(vp_data.vis_list); |
| 2623 | 516 vp_data.vis_list = NULL; |
| 517 } | |
| 2313 | 518 |
| 519 for (node = lowlevel_list; node; node = g_list_next(node)) { | |
| 520 lp = LOWLEVEL_PLUGIN(node->data); | |
| 521 if (lp && lp->cleanup) { | |
| 522 lp->cleanup(); | |
| 523 GDK_THREADS_LEAVE(); | |
| 524 while (g_main_context_iteration(NULL, FALSE)); | |
| 525 GDK_THREADS_ENTER(); | |
| 526 } | |
| 527 g_module_close(lp->handle); | |
| 528 } | |
| 529 | |
| 2623 | 530 if (lowlevel_list != NULL) |
| 531 { | |
| 2313 | 532 g_list_free(lowlevel_list); |
| 2623 | 533 lowlevel_list = NULL; |
| 534 } | |
| 535 | |
| 536 /* XXX: vfs will crash otherwise. -nenolod */ | |
| 537 if (vfs_transports != NULL) | |
| 538 { | |
| 539 g_list_free(vfs_transports); | |
| 540 vfs_transports = NULL; | |
| 541 } | |
|
2682
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2624
diff
changeset
|
542 |
|
c3cd6e47faf6
[svn] - make the evil 'reload plugins' button behave a bit better
giacomo
parents:
2624
diff
changeset
|
543 g_hash_table_destroy( plugin_matrix ); |
| 2313 | 544 } |
