summaryrefslogtreecommitdiff
path: root/apps
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2015-10-10 06:32:51 +0200
committerChristian Pointner <equinox@spreadspace.org>2015-10-10 06:32:51 +0200
commitbe3711cd809446c8ea3ab06a8f39e481bd429ca5 (patch)
treeb81e43bae71026c191da22f40310b44143f1cf12 /apps
parentmidi is now using a thread as well (diff)
improved error handling
Diffstat (limited to 'apps')
-rw-r--r--apps/dolmetschctl.c2
-rw-r--r--apps/osc.c21
2 files changed, 15 insertions, 8 deletions
diff --git a/apps/dolmetschctl.c b/apps/dolmetschctl.c
index fb8f30d..cdf95bb 100644
--- a/apps/dolmetschctl.c
+++ b/apps/dolmetschctl.c
@@ -44,7 +44,7 @@ void print_version()
int main(int argc, char* argv[])
{
osc_t o;
- if(osc_init(&o, "7770"))
+ if(osc_init(&o, "1200"))
return -1;
midi_t m;
diff --git a/apps/osc.c b/apps/osc.c
index 66b281a..7effa54 100644
--- a/apps/osc.c
+++ b/apps/osc.c
@@ -23,7 +23,7 @@
#include "config.h"
#include <stdio.h>
-#include <stdlib.h>
+#include <error.h>
#include <assert.h>
#include "osc.h"
@@ -31,7 +31,7 @@
static void print_error(int num, const char *msg, const char *path)
{
- fprintf(stderr, "liblo server error %d in path %s: %s\n", num, path, msg);
+ error(0, 0, "liblo server error %d in path %s: %s", num, path, msg);
}
static int generic_handler(const char *path, const char *types, lo_arg ** argv,
@@ -54,9 +54,12 @@ int osc_init(osc_t* o, const char* port)
{
assert(o != NULL);
- // TODO: what happends when this fails?
o->st_ = lo_server_thread_new(port, print_error);
- lo_server_thread_add_method(o->st_, NULL, NULL, generic_handler, NULL);
+ if(!o->st_)
+ return -1;
+
+ if(!lo_server_thread_add_method(o->st_, NULL, NULL, generic_handler, NULL))
+ return -1;
return 0;
}
@@ -65,8 +68,9 @@ int osc_start(osc_t* o)
{
assert(o != NULL);
- // TODO: what happends when this fails?
- lo_server_thread_start(o->st_);
+ int ret = lo_server_thread_start(o->st_);
+ if(ret)
+ error(0, ret, "faild to create osc thread");
return 0;
}
@@ -75,7 +79,10 @@ int osc_stop(osc_t* o)
{
assert(o != NULL);
- // TODO: what happends when this fails?
+ int ret = lo_server_thread_stop(o->st_);
+ if(ret)
+ error(0, ret, "faild to stop osc thread");
+
lo_server_thread_free(o->st_);
return 0;