diff options
author | Christian Pointner <equinox@spreadspace.org> | 2015-10-12 07:45:36 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2015-10-12 07:45:36 +0200 |
commit | 72f7565e3210dfc8c068962fdcae7c99db5d6557 (patch) | |
tree | 6c54e6a0cfb3eefd91b7a724dc3b1b5e5c922058 /client/dolmetschctl-client.c | |
parent | added support for midi (diff) |
added inital osc support
Diffstat (limited to 'client/dolmetschctl-client.c')
-rw-r--r-- | client/dolmetschctl-client.c | 44 |
1 files changed, 26 insertions, 18 deletions
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 <alsa/asoundlib.h> #include "midi.h" -/* #include "osc.h" */ +#include "osc.h" void print_version() @@ -61,8 +61,7 @@ void print_usage() printf(" -o <host>:<port> 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 <host>:<port>", 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; } |