diff options
author | Christian Pointner <equinox@spreadspace.org> | 2015-10-10 07:56:56 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2015-10-10 07:56:56 +0200 |
commit | 57fc2e284684aab5b6bb3b56d0035fda4b1e63b3 (patch) | |
tree | 7b42397793ca55ccbcac47ee7188d5d9a6ccd396 /apps/dolmetschctl.c | |
parent | midi is back from threded to async io (diff) |
got rid of threads entirely
Diffstat (limited to 'apps/dolmetschctl.c')
-rw-r--r-- | apps/dolmetschctl.c | 29 |
1 files changed, 18 insertions, 11 deletions
diff --git a/apps/dolmetschctl.c b/apps/dolmetschctl.c index 26b8e83..b8f9197 100644 --- a/apps/dolmetschctl.c +++ b/apps/dolmetschctl.c @@ -47,12 +47,20 @@ int main_loop(osc_t* o, midi_t* m) printf("main_loop just started\n"); - int npfds; - struct pollfd *pfds; + int midi_npfds_offset = 0; + int midi_npfds = midi_get_poll_fd_count(m); + assert(midi_npfds > 0); - npfds = midi_get_poll_desc_count(m); - pfds = alloca(npfds * sizeof(struct pollfd)); - midi_get_poll_desc(m, pfds, npfds); + 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; + struct pollfd *pfds = alloca(npfds * sizeof(struct pollfd)); + + + midi_get_poll_fds(m, &(pfds[midi_npfds_offset]), midi_npfds); + osc_get_poll_fds(o, &(pfds[osc_npfds_offset]), osc_npfds); printf("main_loop running...\n"); for (;;) { @@ -69,7 +77,11 @@ int main_loop(osc_t* o, midi_t* m) continue; } - ret = midi_handle_revents(m, pfds, npfds); + ret = midi_handle_revents(m, &(pfds[midi_npfds_offset]), midi_npfds); + if(ret) + break; + + ret = osc_handle_revents(o, &(pfds[osc_npfds_offset]), osc_npfds); if(ret) break; } @@ -87,12 +99,7 @@ int main(int argc, char* argv[]) if(midi_init(&m, "hw:2,0,0")) return -1; - if(osc_start(&o)) - return -1; - int ret = main_loop(&o, &m); - osc_stop(&o); - return ret; } |