The unified diff between revisions [4839c414..] and [43bb367e..] is displayed below. It can also be downloaded as a raw diff.

This diff has been restricted to the following files: 'src/lsi/main.c'

#
# old_revision [4839c414876f813b3873cc350a8e42d6c01957fc]
# new_revision [43bb367e69d2a944206fd7f641ce73111e4bb780]
#
# patch "src/lsi/main.c"
#  from [b1a9748d1dc7a4bb63c8a08ad412bae381e0dadf]
#    to [dabb12419380d84d4c7403175a31f80ac42f3240]
#
============================================================
--- src/lsi/main.c	b1a9748d1dc7a4bb63c8a08ad412bae381e0dadf
+++ src/lsi/main.c	dabb12419380d84d4c7403175a31f80ac42f3240
@@ -2,18 +2,25 @@
 
 #include <signal.h>
 #include <stdlib.h>
+#include <stdio.h>
 #include <err.h>
 #include "vm.h"
-#include "dmx.h"
-#include "midi.h"
-#include "beatdetect.h"
-#include "mouse.h"
+#include "plugins.h"
 
+/* This macro exists purely to shorten subsequent lines for readability */
+#define PT(i) plugins_table[i]
+
 void finish(void)
 {
-	dmx_close();
-	midi_close();
-	beatdetect_close();
+	int i;
+
+	for (i = nplugins-1; i >= 0; i--) {
+		printf("Shutting down plugin '%s'\n", PT(i).pl_name);
+		(PT(i).pl_shutdown)();
+		printf("Plugin '%s' shut down\n", PT(i).pl_name);
+		PT(i).pl_active = 0;
+	}
+
 	exit(0);
 }
 
@@ -24,6 +31,8 @@ int main(int argc, char *argv[])
 
 int main(int argc, char *argv[])
 {
+	int i;
+
 	argv++;
 	argc--;
 	if (argc != 1)
@@ -31,10 +40,20 @@ int main(int argc, char *argv[])
 	vm_init();
 	vm_load(argv[0]);
 	signal(SIGINT, sigint_handler);
-	midi_init();
-	dmx_init();
-	beatdetect_init();
-	mouse_init();
+
+	/* Initialise plugins */
+	for (i = 0; i < nplugins; i++) {
+		printf("Initialising plugin '%s'\n", PT(i).pl_name);
+		if ((PT(i).pl_init)()) {
+			printf("Plugin '%s' initialised\n", PT(i).pl_name);
+			PT(i).pl_active = 1;
+		} else {
+			printf("Plugin '%s' failed\n", PT(i).pl_name);
+			PT(i).pl_active = 0;
+		}
+	}
+
+	/* Showtime */
 	vm_spawn("main");
 	vm_run();
 	finish();