Mercurial > audlegacy
comparison src/audacious/pluginenum.c @ 3232:2453bf125b4f trunk
Automated merge with ssh://hg.atheme.org//hg/audacious
| author | William Pitcock <nenolod@atheme-project.org> |
|---|---|
| date | Fri, 03 Aug 2007 20:39:42 -0500 |
| parents | 06baa146fc1d 2619f4c62abe |
| children | e21930ccd5a8 |
comparison
equal
deleted
inserted
replaced
| 3231:06baa146fc1d | 3232:2453bf125b4f |
|---|---|
| 48 #include "effect.h" | 48 #include "effect.h" |
| 49 #include "general.h" | 49 #include "general.h" |
| 50 #include "input.h" | 50 #include "input.h" |
| 51 #include "output.h" | 51 #include "output.h" |
| 52 #include "visualization.h" | 52 #include "visualization.h" |
| 53 | 53 #include "discovery.h" |
| 54 const gchar *plugin_dir_list[] = { | 54 const gchar *plugin_dir_list[] = { |
| 55 PLUGINSUBS, | 55 PLUGINSUBS, |
| 56 NULL | 56 NULL |
| 57 }; | 57 }; |
| 58 | 58 |
| 59 GHashTable *plugin_matrix = NULL; | 59 GHashTable *plugin_matrix = NULL; |
| 60 GList *lowlevel_list = NULL; | 60 GList *lowlevel_list = NULL; |
| 61 | |
| 62 extern GList *vfs_transports; | 61 extern GList *vfs_transports; |
| 63 | 62 |
| 64 static gint | 63 static gint |
| 65 inputlist_compare_func(gconstpointer a, gconstpointer b) | 64 inputlist_compare_func(gconstpointer a, gconstpointer b) |
| 66 { | 65 { |
| 109 return strcasecmp(ap->description, bp->description); | 108 return strcasecmp(ap->description, bp->description); |
| 110 else | 109 else |
| 111 return 0; | 110 return 0; |
| 112 } | 111 } |
| 113 | 112 |
| 113 static gint | |
| 114 discoverylist_compare_func(gconstpointer a, gconstpointer b) | |
| 115 { | |
| 116 const DiscoveryPlugin *ap = a, *bp = b; | |
| 117 if(ap->description && bp->description) | |
| 118 return strcasecmp(ap->description, bp->description); | |
| 119 else | |
| 120 return 0; | |
| 121 } | |
| 122 | |
| 114 static gboolean | 123 static gboolean |
| 115 plugin_is_duplicate(const gchar * filename) | 124 plugin_is_duplicate(const gchar * filename) |
| 116 { | 125 { |
| 117 GList *l; | 126 GList *l; |
| 118 const gchar *basename = g_basename(filename); | 127 const gchar *basename = g_basename(filename); |
| 138 for (l = vp_data.vis_list; l; l = g_list_next(l)) | 147 for (l = vp_data.vis_list; l; l = g_list_next(l)) |
| 139 if (!strcmp(basename, g_basename(VIS_PLUGIN(l->data)->filename))) | 148 if (!strcmp(basename, g_basename(VIS_PLUGIN(l->data)->filename))) |
| 140 return TRUE; | 149 return TRUE; |
| 141 | 150 |
| 142 for (l = lowlevel_list; l; l = g_list_next(l)) | 151 for (l = lowlevel_list; l; l = g_list_next(l)) |
| 143 if (!strcmp(basename, g_basename(VIS_PLUGIN(l->data)->filename))) | 152 if (!strcmp(basename, g_basename(LOWLEVEL_PLUGIN(l->data)->filename))) |
| 153 return TRUE; | |
| 154 | |
| 155 for (l = dp_data.discovery_list; l; l = g_list_next(l)) | |
| 156 if (!strcmp(basename, g_basename(DISCOVERY_PLUGIN(l->data)->filename))) | |
| 144 return TRUE; | 157 return TRUE; |
| 145 | 158 |
| 146 return FALSE; | 159 return FALSE; |
| 147 } | 160 } |
| 148 | 161 |
| 198 VisPlugin *p = VIS_PLUGIN(plugin); | 211 VisPlugin *p = VIS_PLUGIN(plugin); |
| 199 p->disable_plugin = vis_disable_plugin; | 212 p->disable_plugin = vis_disable_plugin; |
| 200 vp_data.vis_list = g_list_append(vp_data.vis_list, p); | 213 vp_data.vis_list = g_list_append(vp_data.vis_list, p); |
| 201 } | 214 } |
| 202 | 215 |
| 216 static void | |
| 217 discovery_plugin_init(Plugin * plugin) | |
| 218 { | |
| 219 DiscoveryPlugin *p = DISCOVERY_PLUGIN(plugin); | |
| 220 dp_data.discovery_list = g_list_append(dp_data.discovery_list, p); | |
| 221 } | |
| 222 | |
| 203 /*******************************************************************/ | 223 /*******************************************************************/ |
| 204 | 224 |
| 205 static void | 225 static void |
| 206 plugin2_dispose(GModule *module, const gchar *str, ...) | 226 plugin2_dispose(GModule *module, const gchar *str, ...) |
| 207 { | 227 { |
| 222 InputPlugin **ip_iter; | 242 InputPlugin **ip_iter; |
| 223 OutputPlugin **op_iter; | 243 OutputPlugin **op_iter; |
| 224 EffectPlugin **ep_iter; | 244 EffectPlugin **ep_iter; |
| 225 GeneralPlugin **gp_iter; | 245 GeneralPlugin **gp_iter; |
| 226 VisPlugin **vp_iter; | 246 VisPlugin **vp_iter; |
| 247 DiscoveryPlugin **dp_iter; | |
| 248 | |
| 227 | 249 |
| 228 if (header->magic != PLUGIN_MAGIC) | 250 if (header->magic != PLUGIN_MAGIC) |
| 229 return plugin2_dispose(module, "plugin <%s> discarded, invalid module magic", filename); | 251 return plugin2_dispose(module, "plugin <%s> discarded, invalid module magic", filename); |
| 230 | 252 |
| 231 if (header->api_version != __AUDACIOUS_PLUGIN_API__) | 253 if (header->api_version != __AUDACIOUS_PLUGIN_API__) |
| 286 PLUGIN(*vp_iter)->filename = g_strdup(filename); | 308 PLUGIN(*vp_iter)->filename = g_strdup(filename); |
| 287 g_print("plugin2 '%s' provides VisPlugin <%p>\n", filename, *vp_iter); | 309 g_print("plugin2 '%s' provides VisPlugin <%p>\n", filename, *vp_iter); |
| 288 vis_plugin_init(PLUGIN(*vp_iter)); | 310 vis_plugin_init(PLUGIN(*vp_iter)); |
| 289 } | 311 } |
| 290 } | 312 } |
| 313 | |
| 314 if (header->dp_list) | |
| 315 { | |
| 316 for (dp_iter = header->dp_list; *dp_iter != NULL; dp_iter++) | |
| 317 { | |
| 318 PLUGIN(*dp_iter)->filename = g_strdup(filename); | |
| 319 g_print("plugin2 '%s' provides DiscoveryPlugin <%p>\n", filename, *dp_iter); | |
| 320 discovery_plugin_init(PLUGIN(*dp_iter)); | |
| 321 } | |
| 322 } | |
| 323 | |
| 291 } | 324 } |
| 292 | 325 |
| 293 void | 326 void |
| 294 plugin2_unload(PluginHeader *header) | 327 plugin2_unload(PluginHeader *header) |
| 295 { | 328 { |
| 370 gchar *dir, **disabled; | 403 gchar *dir, **disabled; |
| 371 GList *node; | 404 GList *node; |
| 372 OutputPlugin *op; | 405 OutputPlugin *op; |
| 373 InputPlugin *ip; | 406 InputPlugin *ip; |
| 374 LowlevelPlugin *lp; | 407 LowlevelPlugin *lp; |
| 408 DiscoveryPlugin *dp; | |
| 375 gint dirsel = 0, i = 0; | 409 gint dirsel = 0, i = 0; |
| 376 | 410 |
| 377 if (!g_module_supported()) { | 411 if (!g_module_supported()) { |
| 378 report_error("Module loading not supported! Plugins will not be loaded.\n"); | 412 report_error("Module loading not supported! Plugins will not be loaded.\n"); |
| 379 return; | 413 return; |
| 383 NULL); | 417 NULL); |
| 384 | 418 |
| 385 #ifndef DISABLE_USER_PLUGIN_DIR | 419 #ifndef DISABLE_USER_PLUGIN_DIR |
| 386 scan_plugins(bmp_paths[BMP_PATH_USER_PLUGIN_DIR]); | 420 scan_plugins(bmp_paths[BMP_PATH_USER_PLUGIN_DIR]); |
| 387 /* | 421 /* |
| 388 * This is in a separate loop so if the user puts them in the | 422 * This is in a separate lo |
| 423 * DiscoveryPlugin *dpop so if the user puts them in the | |
| 389 * wrong dir we'll still get them in the right order (home dir | 424 * wrong dir we'll still get them in the right order (home dir |
| 390 * first) - Zinx | 425 * first) - Zinx |
| 391 */ | 426 */ |
| 392 while (plugin_dir_list[dirsel]) { | 427 while (plugin_dir_list[dirsel]) { |
| 393 dir = g_build_filename(bmp_paths[BMP_PATH_USER_PLUGIN_DIR], | 428 dir = g_build_filename(bmp_paths[BMP_PATH_USER_PLUGIN_DIR], |
| 419 gp_data.enabled_list = NULL; | 454 gp_data.enabled_list = NULL; |
| 420 | 455 |
| 421 vp_data.vis_list = g_list_sort(vp_data.vis_list, vislist_compare_func); | 456 vp_data.vis_list = g_list_sort(vp_data.vis_list, vislist_compare_func); |
| 422 vp_data.enabled_list = NULL; | 457 vp_data.enabled_list = NULL; |
| 423 | 458 |
| 459 dp_data.discovery_list = g_list_sort(dp_data.discovery_list, discoverylist_compare_func); | |
| 460 dp_data.enabled_list = NULL; | |
| 461 | |
| 462 | |
| 424 general_enable_from_stringified_list(cfg.enabled_gplugins); | 463 general_enable_from_stringified_list(cfg.enabled_gplugins); |
| 425 vis_enable_from_stringified_list(cfg.enabled_vplugins); | 464 vis_enable_from_stringified_list(cfg.enabled_vplugins); |
| 426 effect_enable_from_stringified_list(cfg.enabled_eplugins); | 465 effect_enable_from_stringified_list(cfg.enabled_eplugins); |
| 466 discovery_enable_from_stringified_list(cfg.enabled_dplugins); | |
| 427 | 467 |
| 428 g_free(cfg.enabled_gplugins); | 468 g_free(cfg.enabled_gplugins); |
| 429 cfg.enabled_gplugins = NULL; | 469 cfg.enabled_gplugins = NULL; |
| 430 | 470 |
| 431 g_free(cfg.enabled_vplugins); | 471 g_free(cfg.enabled_vplugins); |
| 432 cfg.enabled_vplugins = NULL; | 472 cfg.enabled_vplugins = NULL; |
| 433 | 473 |
| 434 g_free(cfg.enabled_eplugins); | 474 g_free(cfg.enabled_eplugins); |
| 435 cfg.enabled_eplugins = NULL; | 475 cfg.enabled_eplugins = NULL; |
| 476 | |
| 477 g_free(cfg.enabled_dplugins); | |
| 478 cfg.enabled_dplugins = NULL; | |
| 479 | |
| 436 | 480 |
| 437 for (node = op_data.output_list; node; node = g_list_next(node)) { | 481 for (node = op_data.output_list; node; node = g_list_next(node)) { |
| 438 op = OUTPUT_PLUGIN(node->data); | 482 op = OUTPUT_PLUGIN(node->data); |
| 439 /* | 483 /* |
| 440 * Only test basename to avoid problems when changing | 484 * Only test basename to avoid problems when changing |
| 451 ip = INPUT_PLUGIN(node->data); | 495 ip = INPUT_PLUGIN(node->data); |
| 452 if (ip->init) | 496 if (ip->init) |
| 453 ip->init(); | 497 ip->init(); |
| 454 } | 498 } |
| 455 | 499 |
| 500 for (node = dp_data.discovery_list; node; node = g_list_next(node)) { | |
| 501 dp = DISCOVERY_PLUGIN(node->data); | |
| 502 if (dp->init) | |
| 503 dp->init(); | |
| 504 } | |
| 505 | |
| 506 | |
| 456 for (node = lowlevel_list; node; node = g_list_next(node)) { | 507 for (node = lowlevel_list; node; node = g_list_next(node)) { |
| 457 lp = LOWLEVEL_PLUGIN(node->data); | 508 lp = LOWLEVEL_PLUGIN(node->data); |
| 458 if (lp->init) | 509 if (lp->init) |
| 459 lp->init(); | 510 lp->init(); |
| 460 } | 511 } |
| 481 OutputPlugin *op; | 532 OutputPlugin *op; |
| 482 EffectPlugin *ep; | 533 EffectPlugin *ep; |
| 483 GeneralPlugin *gp; | 534 GeneralPlugin *gp; |
| 484 VisPlugin *vp; | 535 VisPlugin *vp; |
| 485 LowlevelPlugin *lp; | 536 LowlevelPlugin *lp; |
| 537 DiscoveryPlugin *dp; | |
| 486 GList *node; | 538 GList *node; |
| 487 | 539 |
| 488 g_message("Shutting down plugin system"); | 540 g_message("Shutting down plugin system"); |
| 489 | 541 |
| 490 if (playback_get_playing()) { | 542 if (playback_get_playing()) { |
| 589 { | 641 { |
| 590 g_list_free(vp_data.vis_list); | 642 g_list_free(vp_data.vis_list); |
| 591 vp_data.vis_list = NULL; | 643 vp_data.vis_list = NULL; |
| 592 } | 644 } |
| 593 | 645 |
| 646 | |
| 647 for (node = get_discovery_list(); node; node = g_list_next(node)) { | |
| 648 dp = DISCOVERY_PLUGIN(node->data); | |
| 649 if (dp && dp->cleanup) { | |
| 650 dp->cleanup(); | |
| 651 GDK_THREADS_LEAVE(); | |
| 652 while (g_main_context_iteration(NULL, FALSE)); | |
| 653 GDK_THREADS_ENTER(); | |
| 654 } | |
| 655 | |
| 656 if (dp->handle) | |
| 657 g_module_close(dp->handle); | |
| 658 } | |
| 659 | |
| 660 if (dp_data.discovery_list != NULL) | |
| 661 { | |
| 662 g_list_free(dp_data.discovery_list); | |
| 663 dp_data.discovery_list = NULL; | |
| 664 } | |
| 665 | |
| 666 | |
| 667 | |
| 594 for (node = lowlevel_list; node; node = g_list_next(node)) { | 668 for (node = lowlevel_list; node; node = g_list_next(node)) { |
| 595 lp = LOWLEVEL_PLUGIN(node->data); | 669 lp = LOWLEVEL_PLUGIN(node->data); |
| 596 if (lp && lp->cleanup) { | 670 if (lp && lp->cleanup) { |
| 597 lp->cleanup(); | 671 lp->cleanup(); |
| 598 GDK_THREADS_LEAVE(); | 672 GDK_THREADS_LEAVE(); |
