Hi all,

I've been trying to get the attached patch to steve at plugin dot org
dot uk.... unfortunately his email address has been unavailable for 5
days now.

The attached patch allows the OSC port a timemachine instance is
listening on to be specified at startup with a -o flag.

Can anyone else commit this to the project's git repository whilst
he's unavailable (providing it's up to scratch of course!) or forward
this on to Steve for me please?

This is the first patch I'll have submitted to a well used open source
project so I'm super keen to see it in timemachines code base.

Many thanks,
Tristan
From 1966d8524d4e4c47c525473bab3b010a168adc98 Mon Sep 17 00:00:00 2001
From: Tristan Strange <[email protected]>
Date: Thu, 29 Dec 2011 21:10:14 +0000
Subject: [PATCH] Added comandline option -o which allows the OSC port
 timemachine is running on to be set at launch.

---
 src/main.c |   22 +++++++++++++++++-----
 src/main.h |    3 ++-
 2 files changed, 19 insertions(+), 6 deletions(-)

diff --git a/src/main.c b/src/main.c
index 2557024..de9f5a5 100644
--- a/src/main.c
+++ b/src/main.c
@@ -85,6 +85,7 @@ int osc_handler(const char *path, const char *types, lo_arg **argv, int argc,
 		lo_message msg, void *user_data);
 int osc_handler_nox(const char *path, const char *types, lo_arg **argv,
 		int argc, lo_message msg, void *user_data);
+char *osc_port = DEFAULT_OSC_PORT;
 #endif
 
 int main(int argc, char *argv[])
@@ -103,7 +104,7 @@ int main(int argc, char *argv[])
     auto_begin_threshold = db2lin(DEFAULT_AUTO_BEGIN_THRESHOLD);
     auto_end_threshold = db2lin(DEFAULT_AUTO_END_THRESHOLD);
 
-    while ((opt = getopt(argc, argv, "hic:t:n:p:f:sab:e:T:")) != -1) {
+    while ((opt = getopt(argc, argv, "hic:t:n:p:f:sab:e:T:o:")) != -1) {
 	switch (opt) {
 	case 'h':
 	    help = 1;
@@ -145,6 +146,11 @@ int main(int argc, char *argv[])
 	case 'T':
 	    auto_end_time = atoi(optarg);
 	    break;
+	case 'o':
+#ifdef HAVE_LIBLO
+	    osc_port = optarg;
+#endif
+	    break;
 	default:
 	    num_ports = 0;
 	    break;
@@ -172,6 +178,9 @@ int main(int argc, char *argv[])
 	fprintf(stderr, "\t-b\tspecify threshold above which automatic recording will begin\n");
 	fprintf(stderr, "\t-e\tspecify threshold below which automatic recording will end\n");
 	fprintf(stderr, "\t-T\tspecify silence length before automatic recording ends\n");
+#ifdef HAVE_LIBLO
+	fprintf(stderr, "\t-o\tspecify the OSC port timemachine will listen on\n");
+#endif
 	fprintf(stderr, "\n");
 	fprintf(stderr, "\tchannels must be in the range 1-8, default %d\n",
 			DEFAULT_NUM_PORTS);
@@ -182,6 +191,9 @@ int main(int argc, char *argv[])
 	fprintf(stderr, "\tbegin-threshold, default %.1f dB\n", DEFAULT_AUTO_BEGIN_THRESHOLD);
 	fprintf(stderr, "\tend-threshold, default %.1f dB\n", DEFAULT_AUTO_END_THRESHOLD);
 	fprintf(stderr, "\tend-time, default %d secs\n", DEFAULT_AUTO_END_TIME);
+#ifdef HAVE_LIBLO
+	fprintf(stderr, "\tosc-port, default %s\n", DEFAULT_OSC_PORT);
+#endif
 	fprintf(stderr, "\n");
 	fprintf(stderr, "specifying port names to connect to on the command line overrides -c\n\n");
 	exit(1);
@@ -258,13 +270,13 @@ int main(int argc, char *argv[])
 #ifdef HAVE_LIBREADLINE
     if (console || !getenv("DISPLAY") || getenv("DISPLAY")[0] == '\0') {
 #ifdef HAVE_LIBLO
-      lo_server_thread st = lo_server_thread_new(OSC_PORT, NULL);
+      lo_server_thread st = lo_server_thread_new(osc_port, NULL);
       if (st) {
 	  lo_server_thread_add_method(st, "/start", "", osc_handler_nox, (void *)1);
 	  lo_server_thread_add_method(st, "/stop", "", osc_handler_nox, (void *)0);
 	  lo_server_thread_start(st);
 	  printf("Listening for OSC requests on osc.udp://localhost:%s\n",
-	    OSC_PORT);
+	    osc_port);
       }
 #endif
 
@@ -311,13 +323,13 @@ int main(int argc, char *argv[])
       g_timeout_add(100, meter_tick, NULL);
 
 #ifdef HAVE_LIBLO
-    lo_server_thread st = lo_server_thread_new(OSC_PORT, NULL);
+    lo_server_thread st = lo_server_thread_new(osc_port, NULL);
     if (st) {
 	lo_server_thread_add_method(st, "/start", "", osc_handler, (void *)1);
 	lo_server_thread_add_method(st, "/stop", "", osc_handler, (void *)0);
 	lo_server_thread_start(st);
 	printf("Listening for OSC requests on osc.udp://localhost:%s\n",
-	       OSC_PORT);
+	       osc_port);
     }
 #endif
 
diff --git a/src/main.h b/src/main.h
index 21eaf43..68ae319 100644
--- a/src/main.h
+++ b/src/main.h
@@ -20,7 +20,7 @@
 #define DEFAULT_FORMAT 	"wav"
 #endif
 
-#define OSC_PORT "7133"
+#define DEFAULT_OSC_PORT "7133"
 
 #define DEFAULT_AUTO_BEGIN_THRESHOLD	-35.0
 #define DEFAULT_AUTO_END_THRESHOLD	DEFAULT_AUTO_BEGIN_THRESHOLD
@@ -42,5 +42,6 @@ extern float auto_end_threshold;
 extern unsigned int auto_end_time;
 extern jack_client_t *client;
 extern jack_port_t *ports[MAX_PORTS];
+extern char *osc_port;
 
 #endif
-- 
1.7.5.4

_______________________________________________
Linux-audio-dev mailing list
[email protected]
http://lists.linuxaudio.org/listinfo/linux-audio-dev

Reply via email to