The unified diff between revisions [4839c414..] and [9cb69bf6..] 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 [9cb69bf681632171c5140ab3801212de4c31e6b2]
#
# patch "src/lsi/main.c"
#  from [b1a9748d1dc7a4bb63c8a08ad412bae381e0dadf]
#    to [9e783639920424728a7a1b8c3984eb30a7ecfe4a]
#
============================================================
--- src/lsi/main.c	b1a9748d1dc7a4bb63c8a08ad412bae381e0dadf
+++ src/lsi/main.c	9e783639920424728a7a1b8c3984eb30a7ecfe4a
@@ -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_init)();
+		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();