diff options
-rw-r--r-- | deadbeef.h | 4 | ||||
-rw-r--r-- | main.c | 1 | ||||
-rw-r--r-- | plugins.c | 19 | ||||
-rw-r--r-- | plugins.h | 5 |
4 files changed, 28 insertions, 1 deletions
@@ -626,6 +626,10 @@ typedef struct DB_plugin_s { // it is called after all plugin's start method was executed // can be NULL int (*connect) (void); + + // opposite of connect, will be called before stop, while all plugins are still + // in "started" state + int (*disconnect) (void); // exec_cmdline may be called at any moment when user sends commandline to player // can be NULL if plugin doesn't support commandline processing @@ -834,6 +834,7 @@ main (int argc, char *argv[]) { // plugins might still hood references to playitems, // and query configuration in background // so unload everything 1st before final cleanup + plug_disconnect_all (); plug_unload_all (); // at this point we can simply do exit(0), but let's clean up for debugging @@ -887,6 +887,9 @@ plug_connect_all (void) { if (plug->plugin->connect () < 0) { fprintf (stderr, "plugin %s failed to connect to dependencies, deactivated.\n", plug->plugin->name); + if (plug->plugin->disconnect) { + plug->plugin->disconnect (); + } if (plug->plugin->stop) { plug->plugin->stop (); } @@ -914,6 +917,22 @@ plug_connect_all (void) { } void +plug_disconnect_all (void) { + trace ("plug_disconnect_all\n"); + plugin_t *plug; + plugin_t *prev = NULL; + for (plug = plugins; plug;) { + if (plug->plugin->disconnect) { + if (plug->plugin->disconnect () < 0) { + trace ("plugin %s failed to disconnect\n", plug->plugin->name); + } + } + prev = plug; + plug = plug->next; + } +} + +void plug_unload_all (void) { trace ("plug_unload_all\n"); plugin_t *p; @@ -28,10 +28,13 @@ int plug_load_all (void); void +plug_unload_all (void); + +void plug_connect_all (void); void -plug_unload_all (void); +plug_disconnect_all (void); void plug_cleanup (void); |