summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2010-12-28 22:18:58 +0100
committerGravatar waker <wakeroid@gmail.com>2010-12-28 22:18:58 +0100
commite1bec0e410440034be6457e3dafe490e07683f55 (patch)
treeb2c1aa2be9827ec840e3f08abe523c609410d282
parentfb04911887b9003d5fc99694cf556f32fab7f125 (diff)
nuked old plugin activate/deactivate/nostop code;
improved plugin start and connect code
-rw-r--r--deadbeef.h10
-rw-r--r--plugins.c128
-rw-r--r--plugins/alsa/alsa.c1
-rw-r--r--plugins/converter/Makefile4
-rw-r--r--plugins/gtkui/gtkui.c6
-rw-r--r--plugins/gtkui/prefwin.c21
-rw-r--r--plugins/nullout/nullout.c1
-rw-r--r--plugins/oss/oss.c1
8 files changed, 93 insertions, 79 deletions
diff --git a/deadbeef.h b/deadbeef.h
index 98c12017..e3e24440 100644
--- a/deadbeef.h
+++ b/deadbeef.h
@@ -533,7 +533,6 @@ typedef struct {
struct DB_dsp_s **(*plug_get_dsp_list) (void);
struct DB_playlist_s **(*plug_get_playlist_list) (void);
struct DB_plugin_s **(*plug_get_list) (void);
- int (*plug_activate) (struct DB_plugin_s *p, int activate);
const char * (*plug_get_decoder_id) (const char *id);
void (*plug_remove_decoder_id) (const char *id);
struct DB_plugin_s *(*plug_get_for_id) (const char *id);
@@ -597,10 +596,11 @@ typedef struct DB_plugin_s {
// plugin version
int16_t version_major;
int16_t version_minor;
- // may be deactivated on failures after load
- int inactive;
- // prevent plugin from being dynamically stopped
- int nostop;
+
+ uint32_t flags; // currently unused
+ uint32_t reserved1;
+ uint32_t reserved2;
+ uint32_t reserved3;
// any of those can be left NULL
// though it's much better to fill them with something useful
diff --git a/plugins.c b/plugins.c
index 645f3707..0e4609d1 100644
--- a/plugins.c
+++ b/plugins.c
@@ -259,7 +259,6 @@ static DB_functions_t deadbeef_api = {
.plug_get_dsp_list = plug_get_dsp_list,
.plug_get_playlist_list = plug_get_playlist_list,
.plug_get_list = plug_get_list,
- .plug_activate = plug_activate,
.plug_get_decoder_id = plug_get_decoder_id,
.plug_remove_decoder_id = plug_remove_decoder_id,
.plug_get_for_id = plug_get_for_id,
@@ -480,7 +479,7 @@ plug_event_call (DB_event_t *ev) {
mutex_lock (mutex);
for (int i = 0; i < MAX_HANDLERS; i++) {
- if (handlers[ev->event][i].plugin && !handlers[ev->event][i].plugin->inactive) {
+ if (handlers[ev->event][i].plugin) {
handlers[ev->event][i].callback (ev, handlers[ev->event][i].data);
}
}
@@ -592,6 +591,41 @@ static int dirent_alphasort (const struct dirent **a, const struct dirent **b) {
return strcmp ((*a)->d_name, (*b)->d_name);
}
+void
+plug_remove_plugin (void *p) {
+ int i;
+ for (i = 0; g_plugins[i]; i++) {
+ if (g_plugins[i] == p) {
+ memmove (&g_plugins[i], &g_plugins[i+1], (MAX_PLUGINS+1-i-1) * sizeof (void*));
+ }
+ }
+ for (i = 0; g_decoder_plugins[i]; i++) {
+ if (g_decoder_plugins[i] == p) {
+ memmove (&g_decoder_plugins[i], &g_decoder_plugins[i+1], (MAX_DECODER_PLUGINS+1-i-1) * sizeof (void*));
+ }
+ }
+ for (i = 0; g_vfs_plugins[i]; i++) {
+ if (g_vfs_plugins[i] == p) {
+ memmove (&g_vfs_plugins[i], &g_vfs_plugins[i+1], (MAX_VFS_PLUGINS+1-i-1) * sizeof (void*));
+ }
+ }
+ for (i = 0; g_dsp_plugins[i]; i++) {
+ if (g_dsp_plugins[i] == p) {
+ memmove (&g_dsp_plugins[i], &g_dsp_plugins[i+1], (MAX_DSP_PLUGINS+1-i-1) * sizeof (void*));
+ }
+ }
+ for (i = 0; g_output_plugins[i]; i++) {
+ if (g_output_plugins[i] == p) {
+ memmove (&g_output_plugins[i], &g_output_plugins[i+1], (MAX_OUTPUT_PLUGINS+1-i-1) * sizeof (void*));
+ }
+ }
+ for (i = 0; g_playlist_plugins[i]; i++) {
+ if (g_playlist_plugins[i] == p) {
+ memmove (&g_playlist_plugins[i], &g_playlist_plugins[i+1], (MAX_PLAYLIST_PLUGINS+1-i-1) * sizeof (void*));
+ }
+ }
+}
+
int
plug_load_all (void) {
#if DISABLE_VERSIONCHECK
@@ -785,12 +819,32 @@ plug_load_all (void) {
}
}
// start plugins
- for (plug = plugins; plug; plug = plug->next) {
+ plugin_t *prev = NULL;
+ for (plug = plugins; plug;) {
if (plug->plugin->start) {
if (plug->plugin->start () < 0) {
- plug->plugin->inactive = 1;
+ fprintf (stderr, "plugin %s failed to start, deactivated.\n", plug->plugin->name);
+ if (plug->plugin->stop) {
+ plug->plugin->stop ();
+ }
+ if (plug->handle) {
+ dlclose (plug->handle);
+ }
+ plug_remove_plugin (plug->plugin);
+ if (prev) {
+ prev->next = plug->next;
+ }
+ else {
+ plugins = plug->next;
+ }
+ plugin_t *next = plug->next;
+ free (plug);
+ plug = next;
+ continue;
}
}
+ prev = plug;
+ plug = plug->next;
}
// trace ("numplugins: %d, numdecoders: %d, numvfs: %d\n", numplugins, numdecoders, numvfs);
g_plugins[numplugins] = NULL;
@@ -811,12 +865,34 @@ plug_load_all (void) {
void
plug_connect_all (void) {
plugin_t *plug;
- for (plug = plugins; plug; plug = plug->next) {
+ plugin_t *prev = NULL;
+ for (plug = plugins; plug;) {
if (plug->plugin->connect) {
if (plug->plugin->connect () < 0) {
- plug->plugin->inactive = 1;
+ fprintf (stderr, "plugin %s failed to connect to dependencies, deactivated.\n", plug->plugin->name);
+
+ if (plug->plugin->stop) {
+ plug->plugin->stop ();
+ }
+ if (plug->handle) {
+ dlclose (plug->handle);
+ }
+ plug_remove_plugin (plug->plugin);
+
+ if (prev) {
+ prev->next = plug->next;
+ }
+ else {
+ plugins = plug->next;
+ }
+ plugin_t *next = plug->next;
+ free (plug);
+ plug = next;
+ continue;
}
}
+ prev = plug;
+ plug = plug->next;
}
}
@@ -886,46 +962,6 @@ plug_get_list (void) {
return g_plugins;
}
-int
-plug_activate (DB_plugin_t *plug, int activate) {
- if (plug->inactive && !activate) {
- return -1;
- }
- if (!plug->inactive && activate) {
- return -1;
- }
- if (activate) {
- if (plug->start) {
- if (!plug->start ()) {
- plug->inactive = 0;
- }
- else {
- trace ("failed to start plugin %s\n", plug->name);
- return -1;
- }
- return 0;
- }
- else {
- return -1;
- }
- }
- else {
- if (plug->stop) {
- if (!plug->stop ()) {
- plug->inactive = 1;
- }
- else {
- trace ("failed to stop plugin %s\n", plug->name);
- return -1;
- }
- return 0;
- }
- else {
- return -1;
- }
- }
-}
-
DB_output_t *
plug_get_output (void) {
return output_plugin;
diff --git a/plugins/alsa/alsa.c b/plugins/alsa/alsa.c
index 68981512..ea622981 100644
--- a/plugins/alsa/alsa.c
+++ b/plugins/alsa/alsa.c
@@ -699,7 +699,6 @@ static DB_output_t plugin = {
DB_PLUGIN_SET_API_VERSION
.plugin.version_major = 1,
.plugin.version_minor = 0,
- .plugin.nostop = 1,
.plugin.type = DB_PLUGIN_OUTPUT,
.plugin.name = "ALSA output plugin",
.plugin.descr = "plays sound through linux standard alsa library",
diff --git a/plugins/converter/Makefile b/plugins/converter/Makefile
index 2b062f84..7cd742a0 100644
--- a/plugins/converter/Makefile
+++ b/plugins/converter/Makefile
@@ -3,9 +3,9 @@ GUI_OUT=converter_gtkui.so
CC=gcc
-CFLAGS+=-Wall -D_GNU_SOURCE -std=c99 -g -I../..
+CFLAGS+=-Wall -D_GNU_SOURCE -std=c99 -fPIC -g -I../..
-LDFLAGS+=-module -shared -fPIC
+LDFLAGS+=-module -shared
CONVERTER_SOURCES=converter.c
GUI_SOURCES=convgui.c interface.c support.c
diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c
index e8f41e64..abd6a720 100644
--- a/plugins/gtkui/gtkui.c
+++ b/plugins/gtkui/gtkui.c
@@ -1164,11 +1164,13 @@ gtkui_start (void) {
return 0;
}
+static DB_plugin_t *supereq_plugin;
+
gboolean
gtkui_connect_cb (void *none) {
// equalizer
GtkWidget *eq_mi = lookup_widget (mainwin, "view_eq");
- if (!deadbeef->plug_get_for_id ("supereq")) {
+ if (!supereq_plugin) {
gtk_widget_hide (GTK_WIDGET (eq_mi));
}
else {
@@ -1196,6 +1198,7 @@ gtkui_connect_cb (void *none) {
static int
gtkui_connect (void) {
+ supereq_plugin = deadbeef->plug_get_for_id ("supereq");
// need to do it in gtk thread
g_idle_add (gtkui_connect_cb, NULL);
@@ -1262,7 +1265,6 @@ static ddb_gtkui_t plugin = {
.gui.plugin.api_vminor = DB_API_VERSION_MINOR,
.gui.plugin.version_major = 1,
.gui.plugin.version_minor = 0,
- .gui.plugin.nostop = 1,
.gui.plugin.type = DB_PLUGIN_MISC,
.gui.plugin.id = "gtkui",
.gui.plugin.name = "Standard GTK2 user interface",
diff --git a/plugins/gtkui/prefwin.c b/plugins/gtkui/prefwin.c
index 163459d9..38167165 100644
--- a/plugins/gtkui/prefwin.c
+++ b/plugins/gtkui/prefwin.c
@@ -67,27 +67,6 @@ gtk_enum_sound_callback (const char *name, const char *desc, void *userdata) {
}
void
-on_plugin_active_toggled (GtkCellRendererToggle *cell_renderer, gchar *path, GtkTreeModel *model) {
- GtkTreePath *p = gtk_tree_path_new_from_string (path);
- if (p) {
- int *indices = gtk_tree_path_get_indices (p);
- //gtk_tree_path_free (p); // wtf?? gtk crashes on this
- if (indices) {
- DB_plugin_t **plugins = deadbeef->plug_get_list ();
- DB_plugin_t *plug = plugins[*indices];
- gboolean state;
- GtkTreeIter iter;
- gtk_tree_model_get_iter (model, &iter, p);
- gtk_tree_model_get (model, &iter, 0, &state, -1);
- if (!deadbeef->plug_activate (plug, !state)) {
- gtk_list_store_set (GTK_LIST_STORE (model), &iter, 0, !state, -1);
- }
- }
- g_free (indices);
- }
-}
-
-void
preferences_fill_soundcards (void) {
if (!prefwin) {
return;
diff --git a/plugins/nullout/nullout.c b/plugins/nullout/nullout.c
index 627f8a98..2d07a84d 100644
--- a/plugins/nullout/nullout.c
+++ b/plugins/nullout/nullout.c
@@ -192,7 +192,6 @@ static DB_output_t plugin = {
DB_PLUGIN_SET_API_VERSION
.plugin.version_major = 1,
.plugin.version_minor = 0,
- .plugin.nostop = 1,
.plugin.type = DB_PLUGIN_OUTPUT,
.plugin.name = "null output plugin",
.plugin.descr = "doesn't play anything",
diff --git a/plugins/oss/oss.c b/plugins/oss/oss.c
index b78a2290..817c62f6 100644
--- a/plugins/oss/oss.c
+++ b/plugins/oss/oss.c
@@ -307,7 +307,6 @@ static DB_output_t plugin = {
DB_PLUGIN_SET_API_VERSION
.plugin.version_major = 1,
.plugin.version_minor = 0,
- .plugin.nostop = 0,
.plugin.type = DB_PLUGIN_OUTPUT,
.plugin.id = "oss",
.plugin.name = "OSS output plugin",