diff options
Diffstat (limited to 'apps/osc.c')
-rw-r--r-- | apps/osc.c | 21 |
1 files changed, 14 insertions, 7 deletions
@@ -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; |