|
|
|
@ -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 @@ void sigint_handler(int signal)
|
|
|
|
|
|
|
|
|
|
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(); |
|
|
|
|