From 9e00c3ac52f5c289d87a017df8c25fb2d874f254 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Mon, 12 Oct 2015 06:47:36 +0200 Subject: added command line parser midi and osc are now optional --- apps/osc.c | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) (limited to 'apps/osc.c') diff --git a/apps/osc.c b/apps/osc.c index 9172625..656d400 100644 --- a/apps/osc.c +++ b/apps/osc.c @@ -87,6 +87,12 @@ int osc_init(osc_t* o, const char* port) { assert(o != NULL); + o->server_ = NULL; + slist_init(&(o->done_data_), free_osc_done_data); + + if(!port) + return 0; + o->server_ = lo_server_new(port, print_error); if(!o->server_) return -1; @@ -94,20 +100,26 @@ int osc_init(osc_t* o, const char* port) if(!lo_server_add_method(o->server_, "/lang/switch", "s", lang_handler, (void*)o)) return -1; - slist_init(&(o->done_data_), free_osc_done_data); - return 0; } int osc_get_poll_fd_count(osc_t* o) { + assert(o); + + if(!o->server_) + return 0; + return 1; } int osc_get_poll_fds(osc_t* o, struct pollfd *pfds, int npfds) { - assert(o && pfds && npfds == 1); + assert(o); + + if(!o->server_) + return 0; pfds[0].fd = lo_server_get_socket_fd(o->server_); pfds[0].events = POLLIN; @@ -118,7 +130,10 @@ int osc_get_poll_fds(osc_t* o, struct pollfd *pfds, int npfds) int osc_handle_revents(osc_t* o, struct pollfd *pfds, int npfds, mixer_t* x) { - assert(o && pfds && npfds == 1); + assert(o); + + if(!o->server_) + return 0; if(pfds[0].revents & (POLLERR | POLLHUP | POLLNVAL)) { error(0, 0, "OSC: got POLLERR, POLLHUP or POLLNVAL"); -- cgit v1.2.3