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

#
# old_revision [4839c414876f813b3873cc350a8e42d6c01957fc]
# new_revision [9cb69bf681632171c5140ab3801212de4c31e6b2]
#
# patch "src/lsi/Makefile"
#  from [999eaad9d70c213951fc2aa64f21482b53ae2d74]
#    to [1345a82aeacb32dcd1c90dd59c46be291477403c]
# 
# patch "src/lsi/beatdetect.c"
#  from [642aeeccb604d74ca5bee7f38c873a5f8d5077e7]
#    to [c2ea84655e11d044bc31946962707b9b19294c80]
# 
# patch "src/lsi/beatdetect.h"
#  from [4ab1c3af9b334e8af84bf39117006e0c872e0522]
#    to [2f7891142ddc787462d81f89676946cba7f90922]
# 
# patch "src/lsi/dmx.c"
#  from [fd9f9e6aae06abf60b5def045a152dbb6ad9cf3a]
#    to [d291829ae082bb1bea5c8eb16cffc5f0ab62e22b]
# 
# patch "src/lsi/dmx.h"
#  from [f125289da0af614a2c48d4a2d23b0b649d554aa0]
#    to [2fecc5b3a529ce38b9cb8d67603b758ad7324bb1]
# 
# patch "src/lsi/main.c"
#  from [b1a9748d1dc7a4bb63c8a08ad412bae381e0dadf]
#    to [9e783639920424728a7a1b8c3984eb30a7ecfe4a]
# 
# patch "src/lsi/midi.c"
#  from [ef8ca1f8cfebe145ccee1c650cade074fb21acec]
#    to [e3bb7d685410a1480daeb5df7105847d3b750cb4]
# 
# patch "src/lsi/midi.h"
#  from [9f385ba2c799d5263753e0ac33fbb4385ac3b953]
#    to [106bec2b1fefa24ee2002dca43aa5b6aba6646e1]
# 
# patch "src/lsi/mouse.c"
#  from [c096818b43c9e38bc12de94291b888582fa7bcec]
#    to [d0ae140c88791f0131a6ddef426113cde6f3955b]
# 
# patch "src/lsi/mouse.h"
#  from [de751557ec3efdc5f9de41a169c1a865bdc59da4]
#    to [9c7b5a79262f6f55fc1eedfec0efd3c740f1465c]
#
============================================================
--- src/lsi/Makefile	999eaad9d70c213951fc2aa64f21482b53ae2d74
+++ src/lsi/Makefile	1345a82aeacb32dcd1c90dd59c46be291477403c
@@ -2,8 +2,8 @@ PREFIX?=	/usr/local
 
 PREFIX?=	/usr/local
 
-OBJS=	main.o vm.o dmx.o midi.o beatdetect.o fft.o map3d.o mouse.o
-SRCS=	main.c vm.c dmx.c midi.c beatdetect.c fft.c map3d.c mouse.c
+OBJS=	main.o vm.o plugins.o dmx.o midi.o beatdetect.o fft.o map3d.o mouse.o
+SRCS=	main.c vm.c plugins.c dmx.c midi.c beatdetect.c fft.c map3d.c mouse.c
 
 COMMONOBJS=	mem.o hash.o
 COMMONDIR=	../common
============================================================
--- src/lsi/beatdetect.c	642aeeccb604d74ca5bee7f38c873a5f8d5077e7
+++ src/lsi/beatdetect.c	c2ea84655e11d044bc31946962707b9b19294c80
@@ -114,7 +114,7 @@ double beatdetect_getconfidence(void)
 	return confidence;
 }
 
-void beatdetect_init(void)
+int beatdetect_init(void)
 {
 	audio_info_t info, oinfo;
 
@@ -156,6 +156,8 @@ void beatdetect_init(void)
 
 	/* vm_register_blah */
 	vm_register_signal_fd(audiofd, VM_BEATQ);
+
+	return 1;
 }
 
 int beatdetect_read(void)
============================================================
--- src/lsi/beatdetect.h	4ab1c3af9b334e8af84bf39117006e0c872e0522
+++ src/lsi/beatdetect.h	2f7891142ddc787462d81f89676946cba7f90922
@@ -1,6 +1,6 @@
 /* beatdetect.h */
 
-void beatdetect_init(void);
+int beatdetect_init(void);
 void beatdetect_close(void);
 double beatdetect_getphase(void);
 double beatdetect_getconfidence(void);
============================================================
--- src/lsi/dmx.c	fd9f9e6aae06abf60b5def045a152dbb6ad9cf3a
+++ src/lsi/dmx.c	d291829ae082bb1bea5c8eb16cffc5f0ab62e22b
@@ -92,7 +92,7 @@ out:
 	printf("%x %x %x %x %x %x %x %x %x %x %x %x\n", buf[0], buf[1], buf[2], buf[3], buf[4], buf[5], buf[6], buf[7], buf[8], buf[9], buf[10], buf[11]);
 }
 
-void dmx_init(void)
+int dmx_init(void)
 {
 	dmx_open();
 	dmxpacket[0] = 0x7e;
@@ -104,6 +104,7 @@ void dmx_init(void)
 	dmxpacket[DMX_UNIVERSESIZE+5] = 0xe7;
 	dmxuniverse = dmxpacket+5;
 //	dmx_dumpparams();
+	return 1;
 }
 
 void dmx_setchannel(int channel, int value)
============================================================
--- src/lsi/dmx.h	f125289da0af614a2c48d4a2d23b0b649d554aa0
+++ src/lsi/dmx.h	2fecc5b3a529ce38b9cb8d67603b758ad7324bb1
@@ -3,7 +3,7 @@ void dmx_close(void);
 #define DMX_UNIVERSESIZE 512
 
 void dmx_close(void);
-void dmx_init(void);
+int dmx_init(void);
 void dmx_setchannel(int channel, int value);
 void dmx_output(void);
 
============================================================
--- 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();
============================================================
--- src/lsi/midi.c	ef8ca1f8cfebe145ccee1c650cade074fb21acec
+++ src/lsi/midi.c	e3bb7d685410a1480daeb5df7105847d3b750cb4
@@ -16,7 +16,7 @@ int midi_initialised = 0;
 seq_event_rec midi_buf;
 int midi_initialised = 0;
 
-void midi_init(void)
+int midi_init(void)
 {
 	midi_fd = open(PORT, O_NONBLOCK | O_RDONLY, 0);
 	if (midi_fd == -1) {
@@ -25,6 +25,7 @@ void midi_init(void)
 	midi_bytes = 0;
 	midi_initialised = 1;
 	vm_register_signal_fd(midi_fd, VM_MIDIQ);
+	return 1;
 }
 
 void midi_close(void)
============================================================
--- src/lsi/midi.h	9f385ba2c799d5263753e0ac33fbb4385ac3b953
+++ src/lsi/midi.h	106bec2b1fefa24ee2002dca43aa5b6aba6646e1
@@ -1,6 +1,6 @@
 /* midi.h */
 
-void midi_init(void);
+int midi_init(void);
 void midi_close(void);
 int midi_filter(void);
 int midi_read(void);
============================================================
--- src/lsi/mouse.c	c096818b43c9e38bc12de94291b888582fa7bcec
+++ src/lsi/mouse.c	d0ae140c88791f0131a6ddef426113cde6f3955b
@@ -50,7 +50,7 @@ int mouse_x, mouse_y, mouse_z;
 int mouse_initialised = 0;
 int mouse_x, mouse_y, mouse_z;
 
-void mouse_init(void)
+int mouse_init(void)
 {
 	mouse_fd = open(MOUSEDEVICE, O_RDONLY);
 	if (mouse_fd < 0)
@@ -61,6 +61,8 @@ void mouse_init(void)
 	mouse_x = 0;
 	mouse_y = 0;
 	mouse_z = 0;
+
+	return 1;
 }
 
 void mouse_close(void)
============================================================
--- src/lsi/mouse.h	de751557ec3efdc5f9de41a169c1a865bdc59da4
+++ src/lsi/mouse.h	9c7b5a79262f6f55fc1eedfec0efd3c740f1465c
@@ -1,6 +1,6 @@
 /* mouse.h */
 
-void mouse_init(void);
+int mouse_init(void);
 void mouse_close(void);
 int mouse_filter(void);
 void mouse_getpos(int *, int *, int *);