From 72f7565e3210dfc8c068962fdcae7c99db5d6557 Mon Sep 17 00:00:00 2001 From: Christian Pointner Date: Mon, 12 Oct 2015 07:45:36 +0200 Subject: added inital osc support --- client/dolmetschctl-client.c | 44 ++++++++++++++++++++++++++------------------ 1 file changed, 26 insertions(+), 18 deletions(-) (limited to 'client/dolmetschctl-client.c') diff --git a/client/dolmetschctl-client.c b/client/dolmetschctl-client.c index 1f97475..4dbaf5a 100644 --- a/client/dolmetschctl-client.c +++ b/client/dolmetschctl-client.c @@ -31,7 +31,7 @@ #include #include "midi.h" -/* #include "osc.h" */ +#include "osc.h" void print_version() @@ -61,8 +61,7 @@ void print_usage() printf(" -o : the UDP host/port to send OSC messages to\n"); } -/* int main_loop(midi_t* m, osc_t* o) */ -int main_loop(midi_t* m) +int main_loop(midi_t* m, osc_t* o) { int ret = 0; @@ -72,11 +71,11 @@ int main_loop(midi_t* m) int midi_npfds = midi_get_poll_fd_count(m); assert(midi_npfds > 0); - /* int osc_npfds_offset = midi_npfds_offset + midi_npfds; */ - /* int osc_npfds = osc_get_poll_fd_count(o); */ - /* assert(osc_npfds > 0); */ + int osc_npfds_offset = midi_npfds_offset + midi_npfds; + int osc_npfds = osc_get_poll_fd_count(o); + assert(osc_npfds > 0); - int npfds = midi_npfds; // + osc_npfds; + int npfds = midi_npfds + osc_npfds; struct pollfd *pfds = alloca(npfds * sizeof(struct pollfd)); if(!pfds) { error(0, 0, "error while allocating poll fds - stack corrupted??"); @@ -86,7 +85,7 @@ int main_loop(midi_t* m) printf("main_loop running with %d pollfds...\n", npfds); for (;;) { midi_get_poll_fds(m, &(pfds[midi_npfds_offset]), midi_npfds); - /* osc_get_poll_fds(o, &(pfds[osc_npfds_offset]), osc_npfds); */ + osc_get_poll_fds(o, &(pfds[osc_npfds_offset]), osc_npfds); int err = poll(pfds, npfds, 200); if(err < 0 && errno != EINTR) { @@ -98,14 +97,14 @@ int main_loop(midi_t* m) continue; } -// ret = midi_handle_revents(m, &(pfds[midi_npfds_offset]), midi_npfds, o); - ret = midi_handle_revents(m, &(pfds[midi_npfds_offset]), midi_npfds); + ret = midi_handle_revents(m, &(pfds[midi_npfds_offset]), midi_npfds, o); if(ret) break; - /* ret = osc_handle_revents(o, &(pfds[osc_npfds_offset]), osc_npfds, x); */ - /* if(ret) */ - /* break; */ +// ret = osc_handle_revents(o, &(pfds[osc_npfds_offset]), osc_npfds, m); + ret = osc_handle_revents(o, &(pfds[osc_npfds_offset]), osc_npfds); + if(ret) + break; } return ret; @@ -169,16 +168,25 @@ int main(int argc, char* argv[]) return -1; } + char* port = osc_target; + char* host = strsep(&port, ":"); + char* remain = port; + strsep(&remain, ":"); + if(!host || !port || remain) { + error(0, 0, "'%s' is not a valid targets, must be in the format :", osc_target); + print_usage(); + return -1; + } + midi_t m; if(midi_init(&m, midi_dev)) return -1; - /* osc_t o; */ - /* if(osc_init(&o, osc_target)) */ - /* return -1; */ + osc_t o; + if(osc_init(&o, host, port)) + return -1; - /* int ret = main_loop(&m, &o); */ - int ret = main_loop(&m); + int ret = main_loop(&m, &o); return ret; } -- cgit v1.2.3