summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJaromil <jaromil@dyne.org>2008-06-24 12:00:17 (GMT)
committer Jaromil <jaromil@dyne.org>2008-06-24 12:00:17 (GMT)
commitd5e434c8e561bfa9a52fb7cb9ea63a4d8b00fc17 (patch)
treec8a7be3067dd1a1bc45d23884114059819980e1f
parent1f365b161b0dfa2f48b62a1b2e683f2fb67b988b (diff)
last fixes to interactive switchlydia
-rw-r--r--Makefile2
-rw-r--r--cmdline.cpp179
2 files changed, 99 insertions, 82 deletions
diff --git a/Makefile b/Makefile
index be73bb0..9978799 100644
--- a/Makefile
+++ b/Makefile
@@ -14,7 +14,7 @@ SNDLIBS = `pkg-config --libs sndfile`
# debugging flags:
CPPFLAGS = -I. -Iportaudio -Wall -g -ggdb $(AOFLAGS)
# optimized flags:
-#CPPFLAGS = -I. -Ixmlrpc++ -Wall -O2 -fomit-frame-pointer -ffast-math $(GTKFLAGS)
+#CPPFLAGS = -I. -Iportaudio -Wall -O2 -fomit-frame-pointer -ffast-math
diff --git a/cmdline.cpp b/cmdline.cpp
index 23a53b5..fd1ee38 100644
--- a/cmdline.cpp
+++ b/cmdline.cpp
@@ -49,6 +49,8 @@ bool syncstart = false;
bool graphical = false;
bool dummytest = false;
bool rpcdaemon = false;
+bool interactive = true;
+
int rpcdaemonport = 2640;
int videobuf = 64;
@@ -92,9 +94,10 @@ char *help =
" -d --device activate a device (i.e. /dev/video16)\n"
" -b --buffer size of video buffer in KB (default 64)\n"
" -p --playmode playlist mode (play|cont|loop|rand)\n"
-" -a --noaudio don't open the sound device\n";
+" -a --noaudio don't open the sound device\n"
+" -i --nobutton don't run interactively with button\n";
-char *short_options = "-hd:sb:p:tD:a";
+char *short_options = "-hd:sb:p:tD:ai";
const struct option long_options[] = {
{ "help", no_argument, NULL, 'h'},
{ "device", required_argument, NULL, 'd'},
@@ -103,7 +106,8 @@ const struct option long_options[] = {
{ "playmode", required_argument, NULL, 'p'},
{ "test", no_argument, NULL, 't'},
{ "debug", required_argument, NULL, 'D'},
-{ "noaudio", required_argument, NULL, 'a'},
+{ "noaudio", no_argument, NULL, 'a'},
+{ "nobutton", no_argument, NULL, 'i'},
{0, 0, 0, 0}
};
@@ -255,6 +259,10 @@ int cmdline(int argc, char **argv) {
videobuf = atoi(optarg);
break;
+ case 'i':
+ interactive = false;
+ break;
+
case 1:
fd = fopen(optarg,"rb");
if(!fd) {
@@ -323,13 +331,15 @@ int main(int argc, char **argv) {
/////////////////////////////////
// Parallel port
- parport = new ParPort();
- parport->init();
- // flash light at startup
- parport->light(true);
- jsleep(1,0);
- parport->light(false);
- parport->launch();
+ if(interactive) {
+ parport = new ParPort();
+ parport->init();
+ // flash light at startup
+ parport->light(true);
+ jsleep(1,0);
+ parport->light(false);
+ parport->launch();
+ }
/////////////////////////////////
// video files minidrama offsets
@@ -371,84 +381,91 @@ int main(int argc, char **argv) {
//////////////////////////////////////
// live interactive part while playing
- int c, off;
- bool trigger;
- int interval = 100;
- static bool syncer;
-
- for( c=0; c<5; c++) { // cycle thru 5 minidramas
- trigger = false;
- dec = (Decoder*)decoders.begin();
-
- do {
- jsleep(0, interval);
- off = dec->getoffset();
- } while(off < minidrama[c]->fogstart);
-
- A("fogstart of minidrama %u",c);
-
- // fog start: reset button and play sound
- parport->button_reset();
- parport->light(true);
- if(useaudio) sndfile->replay = true;
-
- do {
-
- jsleep(0, interval);
-
- if( parport->button_is_pressed() ) {
+ if(interactive) {
+ int c, off;
+ bool trigger;
+ int interval = 100;
+ static bool syncer;
+
+ for( c=0; c<5; c++) { // cycle thru 5 minidramas
+ trigger = false;
+ dec = (Decoder*)decoders.begin();
+
+ do {
+ jsleep(0, interval);
+ off = dec->getoffset();
+ } while(off < minidrama[c]->fogstart);
+
+ A("fogstart of minidrama %u",c);
+
+ // fog start: reset button and play sound
+ parport->button_reset();
+ parport->light(true);
- parport->light(false);
+ if(useaudio)
+ sndfile->replay = true;
- D("seek to offset %u", minidrama[c]->black);
- /// global seek of all channels
- dec = (Decoder*) decoders.begin();
- syncer = false;
- while(dec) {
+ // skip to minidrama as soon as button is pressed
+ do {
+
+ jsleep(0, interval);
+
+ if( parport->button_is_pressed() ) {
+
+ parport->light(false);
+
+ D("seek to offset %u", minidrama[c]->black);
+ /// global seek of all channels
+ dec = (Decoder*) decoders.begin();
+ syncer = false;
+ while(dec) {
+
+ dec->stop();
+ dec->setup(&syncer, 0);
+ dec->setoffset( minidrama[c]->black );
+ dec->play();
+ dec = (Decoder*) dec->next;
+
+ }
+
+ jsleep(0, interval);
+ syncer = true;
+ break;
+
+ }
+
+ off = dec->getoffset();
+
+ } while(off < minidrama[c]->black);
+
+
+ parport->light(false);
+
+ // fog end: check button and skip if not pressed
+ if(! parport->button_is_pressed() ) {
+ A("no button pressed: skipping minidrama %u", c);
+ D("seek to offset %u", minidrama[c]->enddrama);
+ /// global seek of all channels
+ dec = (Decoder*) decoders.begin();
+ syncer = false;
+ while(dec) {
dec->stop();
dec->setup(&syncer, 0);
- dec->setoffset( minidrama[c]->black );
+ dec->setoffset( minidrama[c]->enddrama );
dec->play();
dec = (Decoder*) dec->next;
-
- }
-
- jsleep(0, interval);
- syncer = true;
- break;
-
- }
-
- off = dec->getoffset();
-
- } while(off < minidrama[c]->black);
-
- parport->light(false);
-
- // fog end: check button and skip if not pressed
- if(! parport->button_is_pressed() ) {
- A("no button pressed: skipping minidrama %u", c);
- D("seek to offset %u", minidrama[c]->enddrama);
- /// global seek of all channels
- dec = (Decoder*) decoders.begin();
- syncer = false;
- while(dec) {
- dec->stop();
- dec->setup(&syncer, 0);
- dec->setoffset( minidrama[c]->enddrama );
- dec->play();
- dec = (Decoder*) dec->next;
- }
- jsleep(0, interval);
- syncer = true;
-
- } else {
- A("button was pressed: showing minidrama %u",c);
- }
-
- parport->button_reset();
-
+ }
+ jsleep(0, interval);
+ syncer = true;
+
+ } else {
+ A("button was pressed: showing minidrama %u",c);
+ }
+
+ parport->button_reset();
+
+ }
}
//////////////////////////////////////