diff options
author | Christian Pointner <equinox@spreadspace.org> | 2015-10-13 02:06:58 +0200 |
---|---|---|
committer | Christian Pointner <equinox@spreadspace.org> | 2015-10-13 02:06:58 +0200 |
commit | 6eabbee4348d0e2ca1b4140133ddc5e1fd2ed2f7 (patch) | |
tree | 1befb8f149f3f58f1e53ffd445e53bcff508e6b1 /client/osc.c | |
parent | sending switching commands over osc works now...ansers to be done. (diff) |
first working version of client
Diffstat (limited to 'client/osc.c')
-rw-r--r-- | client/osc.c | 37 |
1 files changed, 7 insertions, 30 deletions
diff --git a/client/osc.c b/client/osc.c index 79bfd76..79ee76e 100644 --- a/client/osc.c +++ b/client/osc.c @@ -29,6 +29,7 @@ #include <assert.h> #include "osc.h" +#include "midi.h" static void print_error(int num, const char *msg, const char *path) @@ -45,33 +46,19 @@ static int lang_handler(const char *path, const char *types, lo_arg ** argv, if(argc != 1 || !lo_is_string_type((lo_type)types[0])) return 1; - printf("got ack for: lang '%s'\n", &(argv[0]->s)); - - /* search for right task ... */ - /* if(task->done_cb_) */ - /* task->done_cb_(task->done_data_); */ - - /* slist_remove(&(o->tasks_), task); */ +// printf("got ack for: lang '%s'\n", &(argv[0]->s)); + midi_enqueue_cmd((midi_t*)o->m_, &(argv[0]->s)); return 0; } -void free_osc_task(void* ptr) -{ - task_t* task = (task_t*)ptr; - assert(task); - - free(task->lang_); - free(task); -} - -int osc_init(osc_t* o, const char* host, const char* port) +int osc_init(osc_t* o, void* m, const char* host, const char* port) { assert(o != NULL); o->server_ = NULL; o->target_ = lo_address_new(host, port); - slist_init(&(o->tasks_), free_osc_task); + o->m_ = m; if(!port) return 0; @@ -86,19 +73,9 @@ int osc_init(osc_t* o, const char* host, const char* port) return 0; } -int osc_switch_lang(osc_t* o, const char* lang, void (*done_cb)(void*), void* done_data) +int osc_switch_lang(osc_t* o, const char* lang) { - task_t* task = malloc(sizeof(task_t)); - assert(task); - task->state_ = 0; - assert((task->lang_ = strdup(lang))); - task->done_cb_ = done_cb; - task->done_data_ = done_data; - assert(slist_add(&(o->tasks_), task)); - - if(lo_send_from(o->target_, o->server_, LO_TT_IMMEDIATE, "/lang/switch", "s", task->lang_) > 0) - task->state_ = 1; - + lo_send_from(o->target_, o->server_, LO_TT_IMMEDIATE, "/lang/switch", "s", lang); return 0; } |