summaryrefslogtreecommitdiff
path: root/apps/osc.c
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2015-10-10 05:59:43 +0200
committerChristian Pointner <equinox@spreadspace.org>2015-10-10 05:59:43 +0200
commit42791afe69fc2f06a8c606008b933323c55b1039 (patch)
tree369f288509730740d8c3a9158f436f7b2eea7a76 /apps/osc.c
parentadded midi captureing code (diff)
osc know has an own stuct too
Diffstat (limited to 'apps/osc.c')
-rw-r--r--apps/osc.c42
1 files changed, 19 insertions, 23 deletions
diff --git a/apps/osc.c b/apps/osc.c
index 4cba491..701481f 100644
--- a/apps/osc.c
+++ b/apps/osc.c
@@ -30,8 +30,7 @@
static void print_error(int num, const char *msg, const char *path)
{
- printf("liblo server error %d in path %s: %s\n", num, path, msg);
- fflush(stdout);
+ fprintf(stderr, "liblo server error %d in path %s: %s\n", num, path, msg);
}
static int generic_handler(const char *path, const char *types, lo_arg ** argv,
@@ -39,43 +38,40 @@ static int generic_handler(const char *path, const char *types, lo_arg ** argv,
{
int i;
- printf("path: <%s>\n", path);
+ printf("OSC(%s):%s", path, argc ? " ": " <no arguments>\n");
for(i = 0; i < argc; i++) {
- printf("arg %d '%c' ", i, types[i]);
+ printf("arg %d '%c'", i, types[i]);
lo_arg_pp((lo_type)types[i], argv[i]);
- printf("\n");
+ printf("%s", i >= (argc-1) ? "\n" : ", ");
}
- printf("\n");
- fflush(stdout);
return 1;
}
-static int foo_handler(const char *path, const char *types, lo_arg ** argv,
- int argc, void *data, void *user_data)
+
+int osc_init(osc_t* o, const char* port)
{
- printf("%s <- f:%f, i:%d\n", path, argv[0]->f, argv[1]->i);
- fflush(stdout);
+ if(!o)
+ return -1;
+
+ o->st_ = lo_server_thread_new(port, print_error); // TODO: what happends when this fails?
+ lo_server_thread_add_method(o->st_, NULL, NULL, generic_handler, NULL);
return 0;
}
-
-lo_server_thread osc_init(const char* port)
+void osc_start(osc_t* o)
{
- lo_server_thread st = lo_server_thread_new(port, print_error);
- lo_server_thread_add_method(st, NULL, NULL, generic_handler, NULL);
- lo_server_thread_add_method(st, "/foo/bar", "fi", foo_handler, NULL);
+ if(!o)
+ return;
- return st;
+ lo_server_thread_start(o->st_);
}
-void osc_start(lo_server_thread st)
+void osc_stop(osc_t* o)
{
- lo_server_thread_start(st);
-}
+ if(!o)
+ return;
-void osc_stop(lo_server_thread st)
-{
- lo_server_thread_free(st);
+ lo_server_thread_free(o->st_);
}