1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814
|
/*
* SingIt Lyrics Displayer
* Copyright (C) 2000 - 2003 Jan-Marek Glogowski <glogow@stud.fbi.fh-darmstadt.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
/* Based on xmms visualization plugin mechanism */
#ifdef HAVE_CONFIG_H
#include <config.h>
#endif
#include <sys/stat.h>
#include <dirent.h>
#include <stdio.h>
#include <string.h>
#include <gdk/gdk.h>
#include <gtk/gtkmain.h>
#include <xmms/plugin.h>
#include "ltdl_wrapper.h"
#include "singit_debug.h"
// #include "singit/config_gen.h"
#include "singit_main.h"
#include "singit_plugin_data.h"
#include "singit_plugin_scanner.h"
#include "dlg_singit_config.h"
#include "singit_sound_precalcs_private.h"
#include "singit/displayer_plugin.h"
#include "singit/wgt_karaoke.h"
DisplayerPluginData *dp_data = NULL;
#define PLUGINSUBDIR "xmms-singit"
extern VisPlugin singit_vp;
static void scan_dis_plugins(gchar *dirname);
static gboolean plugins_finalize_real(gboolean has_lock);
void dis_plugin_disable(DisplayerPlugin *dp);
static GList *get_dis_plugin_enabled_list(gboolean initialized);
static gint singit_disable_func(gpointer data)
{
GDK_THREADS_ENTER();
singit_vp.disable_plugin(&singit_vp);
GDK_THREADS_LEAVE();
return (FALSE);
}
static gint dislist_compare_func(const void *a, const void *b)
{
return strcasecmp(((DisplayerPlugin *) a)->description, ((DisplayerPlugin *) b)->description);
}
void plugins_init()
{
gchar *dir;
SingitConfigGen *scg_o;
#ifdef CODEDEBUG
DEBUG(8, ("singit_plugin_scanner.c [plugins_init]\n"));
#endif
if (displayer_plugin_data_attach(dp_data) == TRUE)
{ return; }
if (wrp_dlinit() != 0) {
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
"dlopen error: %s", wrp_dlerror());
return;
}
dp_data = DISPLAYER_PLUGIN_DATA(displayer_plugin_data_new());
#ifndef DISABLE_USER_PLUGIN_DIR
dir = g_strconcat(g_get_home_dir(), "/.xmms/Plugins/Visualization", NULL);
scan_dis_plugins(dir);
g_free(dir);
/*
* This is in a separate loop so if the user puts them in the
* wrong dir we'll still get them in the right order (home dir
* first - Zinx
*/
dir = g_strconcat(g_get_home_dir(), "/.xmms/Plugins/Visualization/", PLUGINSUBDIR, NULL);
scan_dis_plugins(dir);
g_free(dir);
#endif
dir = g_strconcat(PLUGIN_DIR, "/", PLUGINSUBDIR, NULL);
scan_dis_plugins(dir);
g_free(dir);
dp_data->displayer_list =
g_list_sort(dp_data->displayer_list, dislist_compare_func);
if ((scg_o = singit_config_gen_attach(STATUS->config)) != NULL) {
dis_plugin_enable_from_stringified_list(GET_SCD->enabled_dplugins);
singit_config_gen_detach(&scg_o);
}
}
static gboolean dis_plugin_is_duplicate_libname(gchar* filename)
{
GList *pl = dp_data->displayer_list;
gchar *base_filename = g_basename(filename);
while (pl != NULL) {
if (wrp_is_same_libname
(((DisplayerPlugin*)pl->data)->handle, base_filename))
{
return TRUE;
}
pl = g_list_next(pl);
}
return FALSE;
}
// libltdl is smart enought to return the same handle for the same lib
// Our wrapper is not, so we just return FALSE - no dup
static gboolean dis_plugin_check_duplicate_handle(lt_dlhandle h)
{
#ifdef HAVE_LTDL_H
GList *pl = dp_data->displayer_list;
while (pl != NULL) {
if (h == ((lt_dlhandle) ((DisplayerPlugin*)pl->data)->handle))
{ return TRUE; }
pl = g_list_next(pl);
}
#endif
return FALSE;
}
static void add_dis_plugin(gchar *filename)
{
lt_dlhandle h;
void *(*gpi) (void);
if (dis_plugin_is_duplicate_libname(filename) == TRUE)
{ return; }
if ((h = wrp_dlopen(filename)) == NULL)
{
g_log (G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
"dlopen error: %s", wrp_dlerror());
return;
}
if ((dis_plugin_check_duplicate_handle(h) == FALSE) &&
((gpi = wrp_dlsym(h, "get_dplugin_info")) != NULL))
{
DisplayerPlugin *p;
p = (DisplayerPlugin *) gpi();
p->handle = (void*) h;
p->filename = g_strdup(filename);
p->singit_session = -1;
p->xmms_session = singit_vp.xmms_session;
p->disable = dis_plugin_disable;
dp_data->displayer_list = g_list_prepend(dp_data->displayer_list, p);
}
else { wrp_dlclose(h); }
}
static void scan_dis_plugins(gchar *dirname)
{
gchar *filename;
DIR *dir;
struct dirent *ent;
struct stat statbuf;
dir = opendir(dirname);
if (!dir)
return;
while ((ent = readdir(dir)) != NULL)
{
// We skip "." and ".." directory entries
if ((strcmp(ent->d_name, ".") == 0) || (strcmp(ent->d_name, "..") == 0))
{ continue; }
filename = g_strdup_printf("%s/%s", dirname, ent->d_name);
if (!stat(filename, &statbuf) && S_ISREG(statbuf.st_mode) &&
wrp_is_libname(filename))
{
add_dis_plugin(filename);
}
g_free(filename);
}
closedir(dir);
}
void plugins_finish(void)
{
DisplayerPlugin *dp;
GList *node;
gboolean init;
SingitConfigGen *scg_o;
#ifdef CODEDEBUG
DEBUG(8, ("singit_plugin_scanner.c [plugins_finish] : "));
#endif
g_return_if_fail(dp_data != NULL);
if (GTK_OBJECT(dp_data)->ref_count > 1) {
displayer_plugin_data_detach(&dp_data);
#ifdef CODEDEBUG
DEBUG(8, ("Just detached\n"));
#endif
return;
}
#ifdef CODEDEBUG
DEBUG(8, ("Real finished\n"));
#endif
init = displayer_plugin_data_lock_init_ext(dp_data, TRUE, FALSE, FALSE);
if ((scg_o = singit_config_gen_attach(STATUS->config)) != NULL)
{
g_free(GET_SCD->enabled_dplugins);
GET_SCD->enabled_dplugins = dis_plugin_stringify_enabled_list();
if ((GET_SCD->enabled_dplugins == NULL) &&
(dp_data->displayer_last != NULL))
{
GET_SCD->enabled_dplugins = g_strdup(wrp_get_libname
(((DisplayerPlugin *) dp_data->displayer_last)->handle));
}
singit_config_save_plugins();
if (init) { singit_config_save_positions(); }
singit_config_gen_detach(&scg_o);
}
if (init) { plugins_finalize_real(TRUE); }
node = get_dis_plugin_list();
while (node)
{
dp = (DisplayerPlugin *) node->data;
wrp_dlclose(dp->handle);
node = g_list_next(node);
}
displayer_plugin_data_detach(&dp_data);
wrp_dlexit();
if (init && (dp_data != NULL))
displayer_plugin_data_unlock_init(dp_data);
}
void dis_plugin_set_time(gint plugin, gint time, GList *real_next)
{
DisplayerPlugin *dp;
GList *node;
if (displayer_plugin_data_lock_plugins(dp_data, TRUE) == FALSE)
{ return; }
if (plugin < 0) {
node = get_dis_plugin_enabled_list(TRUE);
while (node != NULL)
{
dp = (DisplayerPlugin *) node->data;
if ((dp != NULL) && (dp->set_time != NULL))
dp->set_time(time, real_next);
node = g_list_next(node);
}
}
else {
node = g_list_nth(dp_data->displayer_list, plugin);
if (node != NULL &&
g_list_find(get_dis_plugin_enabled_list(TRUE), node->data))
{
dp = (DisplayerPlugin *) node->data;
if ((dp != NULL) && (dp->set_time != NULL))
dp->set_time(time, real_next);
}
else
g_log(G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
"Plugin not available");
}
displayer_plugin_data_unlock_plugins(dp_data);
}
typedef enum {
dpc_set_song = 0,
dpc_update,
dpc_playback_start,
dpc_playback_stop,
dpc_about,
dpc_configure
}
DPCallback;
// Emitter for "seldom" used callbacks
static inline gboolean real_emitter
(GList *node, DPCallback callback, SingitSong *cur_song, gboolean enabled)
{
DisplayerPlugin *dp;
g_return_val_if_fail(node != NULL, FALSE);
g_return_val_if_fail(node->data != NULL, FALSE);
g_return_val_if_fail(dp_data != NULL, FALSE);
dp = (DisplayerPlugin *) node->data;
switch (callback) {
case dpc_about:
if (dp->about)
dp->about();
return TRUE;
case dpc_configure:
if (dp->configure)
dp->configure();
return TRUE;
default: // To suppress compiler warnings
if (enabled == FALSE)
{ return FALSE; }
}
switch (callback) {
case dpc_set_song:
if (dp->set_song)
dp->set_song(cur_song);
break;
case dpc_update:
if (dp->update)
dp->update();
break;
case dpc_playback_start:
if (dp->playback_start)
dp->playback_start();
break;
case dpc_playback_stop:
if (dp->playback_stop)
dp->playback_stop();
break;
default: // To suppress compiler warnings
return FALSE;
}
return TRUE;
}
// if (plugin < 0) ==> for all enabled
static void emit_callback(DPCallback callback, gint plugin, SingitSong *cur_song)
{
GList *node;
gboolean plugins, initialized = TRUE;
g_return_if_fail(dp_data != NULL);
switch (callback) {
case dpc_about:
case dpc_configure:
if (displayer_plugin_data_lock_init(dp_data, &initialized) == FALSE)
{ return; }
plugins = FALSE;
break;
default:
if (displayer_plugin_data_lock_plugins(dp_data, FALSE) == FALSE)
{ return; }
plugins = TRUE;
break;
}
if (plugin < 0) {
node = get_dis_plugin_enabled_list(TRUE);
while (node != NULL)
{
if (real_emitter(node, callback, cur_song, initialized) == FALSE)
{ break; }
node = g_list_next(node);
}
}
else {
node = g_list_nth(dp_data->displayer_list, plugin);
if (node != NULL)
real_emitter(node, callback, cur_song, initialized &&
is_dis_plugin_enabled(plugin));
else
g_log(G_LOG_DOMAIN, G_LOG_LEVEL_CRITICAL,
"Plugin not available");
}
if (plugins == FALSE)
{ displayer_plugin_data_unlock_init(dp_data); }
else
{ displayer_plugin_data_unlock_plugins(dp_data); }
}
void dis_plugin_set_song(gint plugin, SingitSong *cur_song)
{
#ifdef CODEDEBUG
DEBUG(DLV_ALL, ("singit_plugin_scanner.c [dis_plugin_set_song]\n"));
#endif
emit_callback(dpc_set_song, plugin, cur_song);
}
void dis_plugin_update(gint plugin)
{
#ifdef CODEDEBUG
DEBUG(DLV_ALL, ("singit_plugin_scanner.c [dis_plugin_update]\n"));
#endif
emit_callback(dpc_update, plugin, NULL);
}
void dis_plugin_playback_start(gint plugin)
{
#ifdef CODEDEBUG
DEBUG(DLV_ALL, ("singit_plugin_scanner.c [dis_plugin_playback_start]\n"));
#endif
if (!dp_data || dp_data->playback_started)
{ return; }
emit_callback(dpc_playback_start, plugin, NULL);
dp_data->playback_started = TRUE;
}
void dis_plugin_playback_stop(gint plugin)
{
#ifdef CODEDEBUG
DEBUG(DLV_ALL, ("singit_plugin_scanner.c [dis_plugin_playback_stop]\n"));
#endif
if (!dp_data || !dp_data->playback_started) { return; }
emit_callback(dpc_playback_stop, plugin, NULL);
dp_data->playback_started = FALSE;
}
void dis_plugin_about(gint plugin)
{
#ifdef CODEDEBUG
DEBUG(DLV_ALL, ("singit_plugin_scanner.c [dis_plugin_about]\n"));
#endif
emit_callback(dpc_about, plugin, NULL);
}
void dis_plugin_configure(gint plugin)
{
#ifdef CODEDEBUG
DEBUG(DLV_ALL, ("singit_plugin_scanner.c [dis_plugin_configure]\n"));
#endif
emit_callback(dpc_configure, plugin, NULL);
}
void dis_plugin_render_freq(gint16 freq_data[2][256])
{
GList *node;
node = get_dis_plugin_enabled_list(TRUE);
if (node && (STATUS->singit_sound_precalcs != NULL)) {
sigit_sound_precalcs_freq(STATUS->singit_sound_precalcs, &freq_data[0][0]);
}
while (node)
{
if (((DisplayerPlugin *) node->data)->render_freq)
((DisplayerPlugin *) node->data)->render_freq(freq_data, STATUS->singit_sound_precalcs);
node = g_list_next(node);
}
}
void dis_plugin_render_pcm(gint16 pcm_data[2][512])
{
GList *node;
node = get_dis_plugin_enabled_list(TRUE);
if (node && (STATUS->singit_sound_precalcs != NULL)) {
sigit_sound_precalcs_pcm(STATUS->singit_sound_precalcs, &pcm_data[0][0]);
}
while (node)
{
if (((DisplayerPlugin *) node->data)->render_pcm)
((DisplayerPlugin *) node->data)->render_pcm(pcm_data, STATUS->singit_sound_precalcs);
node = g_list_next(node);
}
}
GList *get_dis_plugin_list(void)
{
if (!dp_data) { return NULL; }
return dp_data->displayer_list;
}
static GList *get_dis_plugin_enabled_list(gboolean initialized)
{
if (!dp_data) { return NULL; }
if (initialized && !dp_data->initialized) { return NULL; }
return dp_data->enabled_list;
}
gboolean is_dis_plugin_enabled(gint plugin)
{
gboolean result;
g_return_val_if_fail(dp_data != NULL, FALSE);
result = (dp_data->enabled_list != NULL);
if ((result == TRUE) && (plugin >= 0))
result = (g_list_find(dp_data->enabled_list,
(g_list_nth(dp_data->displayer_list, plugin)->data)) != NULL);
return result;
}
gboolean is_dis_plugin_running(gint plugin)
{
g_return_val_if_fail(dp_data != NULL, FALSE);
if (displayer_plugin_data_lock_init_ext(dp_data, TRUE, FALSE, TRUE) == FALSE)
{ return FALSE; }
displayer_plugin_data_unlock_init(dp_data);
return is_dis_plugin_enabled(plugin);
}
// This is the callback the plugin can use to disable itself
void dis_plugin_disable(DisplayerPlugin *dp)
{
gint i;
#ifdef CODEDEBUG
DEBUG(8, ("singit_plugin_scanner.c [dis_plugin_disable]\n"));
#endif
g_return_if_fail(dp_data != NULL);
g_return_if_fail(dp != NULL);
g_return_if_fail(dp_data->displayer_list != NULL);
i = g_list_index(dp_data->displayer_list, dp);
set_dis_plugin_status(i, FALSE);
config_dis_plugins_rescan();
}
gboolean set_dis_plugin_status(gint plugin, gboolean enable)
{
GList *node;
DisplayerPlugin *dp;
gboolean search;
gboolean initialized;
gboolean result = FALSE;
g_return_val_if_fail(dp_data != NULL, FALSE);
#ifdef CODEDEBUG
DEBUG(DLV_ALL, ("singit_plugin_scanner.c [set_dis_plugin_status] : "));
if (enable) { DEBUG(DLV_ALL, ("Enable\n")); }
else { DEBUG(DLV_ALL, ("Disable\n")); }
#endif
if (displayer_plugin_data_lock_lower(dp_data, &initialized) == FALSE)
{ goto unlock_lower; }
// Find the plugin, look and look if it is (!enable)
if ((guint) plugin >= g_list_length(dp_data->displayer_list))
{ goto unlock_lower; }
node = g_list_nth(dp_data->displayer_list, plugin);
g_goto_label_if_fail(node != NULL, unlock_lower);
g_goto_label_if_fail(node->data != NULL, unlock_lower);
dp = (DisplayerPlugin *) node->data;
search = (g_list_find(dp_data->enabled_list, dp) != NULL);
if (enable == search)
{ goto unlock_lower; }
result = TRUE;
if (enable) {
// Start the displayer plugin
dp_data->enabled_list = g_list_append(dp_data->enabled_list, dp);
if (initialized == FALSE)
{ goto unlock_lower; }
if (dp->init)
dp->init();
if (dp->update)
dp->update();
if (dp->set_song)
dp->set_song(STATUS->song);
STATUS->initialize_plugins = TRUE;
}
else {
// Stop the displayer plugin
if (dp_data->enabled_list->next == NULL)
{ dp_data->displayer_last = dp_data->enabled_list->data; }
dp_data->enabled_list = g_list_remove(dp_data->enabled_list, dp);
if (g_list_find(dp_data->visible_list, dp))
{ dp_data->visible_list = g_list_remove(dp_data->visible_list, dp); }
if (initialized == FALSE)
{ goto unlock_lower; }
if (dp->finish) {
dp->finish();
}
STATUS->initialize_plugins = TRUE;
singit_config_save_positions();
if (!dp_data->enabled_list) {
dp_data->initialized = FALSE;
gtk_idle_add(singit_disable_func, NULL);
}
}
unlock_lower:
if (initialized == TRUE)
{ displayer_plugin_data_unlock_plugins(dp_data); }
else
{ displayer_plugin_data_unlock_init(dp_data); }
return result;
}
gchar *dis_plugin_stringify_enabled_list(void)
{
gchar *enabled_str = NULL, *dest_pos;
const gchar *src_pos;
GList *node;
gint len = 0;
g_return_val_if_fail(dp_data != NULL, NULL);
#ifdef CODEDEBUG
DEBUG(DLV_ALL, ("singit_plugin_scanner.c [dis_plugin_stringify_enabled_list]\n"));
#endif
node = dp_data->enabled_list;
if (node == NULL)
{ return NULL; }
while (node) {
len += strlen(wrp_get_libname
(((DisplayerPlugin *) node->data)->handle)) + 1;
node = g_list_next(node);
}
dest_pos = enabled_str = g_new(gchar, len);
enabled_str[0] = '\0';
node = dp_data->enabled_list;
while (node) {
src_pos = wrp_get_libname
(((DisplayerPlugin *) node->data)->handle);
len = strlen(src_pos);
memcpy(dest_pos, src_pos, len);
dest_pos += len;
dest_pos[0] = ',';
dest_pos++;
node = g_list_next(node);
}
dest_pos--;
dest_pos[0] = '\0';
return enabled_str;
}
void dis_plugin_enable_from_stringified_list(gchar *list)
{
gchar **plugins;
GList *node;
gint i;
DisplayerPlugin *dp;
#ifdef CODEDEBUG
DEBUG(8, ("singit_plugin_scanner.c [dis_plugin_enable_from_stringified_list]\n"));
#endif
if (!list || !strcmp(list, ""))
return;
plugins = g_strsplit(list, ",", 0);
i = 0;
while (plugins[i])
{
node = dp_data->displayer_list;
while (node)
{
if (wrp_is_same_libname(((DisplayerPlugin *) node->data)->handle, plugins[i]))
{
dp = node->data;
dp_data->enabled_list = g_list_append
(dp_data->enabled_list, (DisplayerPlugin *) dp);
}
node = g_list_next(node);
}
i++;
}
g_strfreev(plugins);
}
gboolean plugins_initialize()
{
GList *node;
DisplayerPlugin *dp;
g_return_val_if_fail(dp_data != NULL, FALSE);
#ifdef CODEDEBUG
DEBUG(8, ("singit_plugin_scanner.c [plugins_initialize]\n"));
#endif
if (displayer_plugin_data_lock_init_ext(dp_data, FALSE, FALSE, FALSE) == FALSE)
{ return FALSE; }
node = dp_data->enabled_list;
while (node)
{
dp = node->data;
if (dp->init)
dp->init();
if (dp->update)
dp->update();
// XMMS can't process requests during init, so we don't set the song
node = g_list_next(node);
}
dp_data->initialized = TRUE;
// We have finished the initialization - unlock the plugins
displayer_plugin_data_unlock_plugins(dp_data);
displayer_plugin_data_unlock_init(dp_data);
return TRUE;
}
static gboolean plugins_finalize_real(gboolean has_lock)
{
GList *node;
DisplayerPlugin *dp;
g_return_val_if_fail(dp_data != NULL, FALSE);
#ifdef CODEDEBUG
DEBUG(8, ("singit_plugin_scanner.c [plugins_finalize]\n"));
#endif
if (displayer_plugin_data_lock_init_ext(dp_data, TRUE, has_lock, FALSE) == FALSE)
{ return FALSE; }
// We are going to shut down the plugins - lock them
if (displayer_plugin_data_lock_plugins(dp_data, FALSE) == FALSE)
{ return FALSE; }
node = dp_data->enabled_list;
while (node)
{
dp = node->data;
if (dp->finish) {
dp->finish();
}
node = g_list_next(node);
}
dp_data->initialized = FALSE;
g_list_free(dp_data->visible_list);
dp_data->visible_list = NULL;
if (has_lock == FALSE)
displayer_plugin_data_unlock_init(dp_data);
return TRUE;
}
gboolean plugins_finalize()
{
g_return_val_if_fail(dp_data != NULL, FALSE);
#ifdef CODEDEBUG
DEBUG(8, ("singit_plugin_scanner.c [plugins_finalize]\n"));
#endif
return plugins_finalize_real(FALSE);
}
|