diff options
author | cbdev <cb@cbcdn.com> | 2019-06-30 14:13:22 +0200 |
---|---|---|
committer | cbdev <cb@cbcdn.com> | 2019-06-30 14:13:22 +0200 |
commit | ee75bee08b8fb280fc1d76e8635cf29c576835da (patch) | |
tree | e45d99e30de7982ce6f1b85b0b22bf68b1b27e0e | |
parent | 68f1a58f13997cf052241d6e1177dcbec9a109ec (diff) | |
download | midimonster-ee75bee08b8fb280fc1d76e8635cf29c576835da.tar.gz midimonster-ee75bee08b8fb280fc1d76e8635cf29c576835da.tar.bz2 midimonster-ee75bee08b8fb280fc1d76e8635cf29c576835da.zip |
Update OSC backend to API design
-rw-r--r-- | backends/osc.c | 52 | ||||
-rw-r--r-- | backends/osc.h | 18 |
2 files changed, 35 insertions, 35 deletions
diff --git a/backends/osc.c b/backends/osc.c index 130dd2d..fd1bcd4 100644 --- a/backends/osc.c +++ b/backends/osc.c @@ -16,14 +16,14 @@ int init(){ backend osc = { .name = BACKEND_NAME, - .conf = backend_configure, - .create = backend_instance, - .conf_instance = backend_configure_instance, - .channel = backend_channel, - .handle = backend_set, - .process = backend_handle, - .start = backend_start, - .shutdown = backend_shutdown + .conf = osc_configure, + .create = osc_instance, + .conf_instance = osc_configure_instance, + .channel = osc_map_channel, + .handle = osc_set, + .process = osc_handle, + .start = osc_start, + .shutdown = osc_shutdown }; //register backend @@ -253,13 +253,13 @@ static int osc_validate_path(char* path){ return 0; } -static int backend_configure(char* option, char* value){ +static int osc_configure(char* option, char* value){ fprintf(stderr, "The OSC backend does not take any global configuration\n"); return 1; } -static int backend_configure_instance(instance* inst, char* option, char* value){ - osc_instance* data = (osc_instance*) inst->impl; +static int osc_configure_instance(instance* inst, char* option, char* value){ + osc_instance_data* data = (osc_instance_data*) inst->impl; char* host = NULL, *port = NULL, *token = NULL, *format = NULL; size_t u, p; @@ -394,13 +394,13 @@ static int backend_configure_instance(instance* inst, char* option, char* value) return 1; } -static instance* backend_instance(){ +static instance* osc_instance(){ instance* inst = mm_instance(); if(!inst){ return NULL; } - osc_instance* data = calloc(1, sizeof(osc_instance)); + osc_instance_data* data = calloc(1, sizeof(osc_instance_data)); if(!data){ fprintf(stderr, "Failed to allocate memory\n"); return NULL; @@ -411,9 +411,9 @@ static instance* backend_instance(){ return inst; } -static channel* backend_channel(instance* inst, char* spec){ +static channel* osc_map_channel(instance* inst, char* spec){ size_t u; - osc_instance* data = (osc_instance*) inst->impl; + osc_instance_data* data = (osc_instance_data*) inst->impl; size_t param_index = 0; //check spec for correctness @@ -457,14 +457,14 @@ static channel* backend_channel(instance* inst, char* spec){ return mm_channel(inst, u, 1); } -static int backend_set(instance* inst, size_t num, channel** c, channel_value* v){ +static int osc_set(instance* inst, size_t num, channel** c, channel_value* v){ uint8_t xmit_buf[OSC_XMIT_BUF], *format = NULL; size_t evt = 0, off, members, p; if(!num){ return 0; } - osc_instance* data = (osc_instance*) inst->impl; + osc_instance_data* data = (osc_instance_data*) inst->impl; if(!data->dest_len){ fprintf(stderr, "OSC instance %s does not have a destination, output is disabled (%zu channels)\n", inst->name, num); return 0; @@ -563,11 +563,11 @@ static int backend_set(instance* inst, size_t num, channel** c, channel_value* v return 0; } -static int backend_handle(size_t num, managed_fd* fds){ +static int osc_handle(size_t num, managed_fd* fds){ size_t fd; char recv_buf[OSC_RECV_BUF]; instance* inst = NULL; - osc_instance* data = NULL; + osc_instance_data* data = NULL; ssize_t bytes_read = 0; size_t c; char* osc_fmt = NULL; @@ -581,7 +581,7 @@ static int backend_handle(size_t num, managed_fd* fds){ continue; } - data = (osc_instance*) inst->impl; + data = (osc_instance_data*) inst->impl; do{ if(data->learn){ @@ -639,10 +639,10 @@ static int backend_handle(size_t num, managed_fd* fds){ return 0; } -static int backend_start(){ +static int osc_start(){ size_t n, u, fds = 0; instance** inst = NULL; - osc_instance* data = NULL; + osc_instance_data* data = NULL; //fetch all instances if(mm_backend_instances(BACKEND_NAME, &n, &inst)){ @@ -657,7 +657,7 @@ static int backend_start(){ //update instance identifiers for(u = 0; u < n; u++){ - data = (osc_instance*) inst[u]->impl; + data = (osc_instance_data*) inst[u]->impl; if(data->fd >= 0){ inst[u]->ident = data->fd; @@ -679,10 +679,10 @@ static int backend_start(){ return 0; } -static int backend_shutdown(){ +static int osc_shutdown(){ size_t n, u, c; instance** inst = NULL; - osc_instance* data = NULL; + osc_instance_data* data = NULL; if(mm_backend_instances(BACKEND_NAME, &n, &inst)){ fprintf(stderr, "Failed to fetch instance list\n"); @@ -690,7 +690,7 @@ static int backend_shutdown(){ } for(u = 0; u < n; u++){ - data = (osc_instance*) inst[u]->impl; + data = (osc_instance_data*) inst[u]->impl; for(c = 0; c < data->channels; c++){ free(data->channel[c].path); } diff --git a/backends/osc.h b/backends/osc.h index 5938f12..dc6cb3a 100644 --- a/backends/osc.h +++ b/backends/osc.h @@ -6,14 +6,14 @@ #define OSC_XMIT_BUF 8192 int init(); -static int backend_configure(char* option, char* value); -static int backend_configure_instance(instance* instance, char* option, char* value); -static instance* backend_instance(); -static channel* backend_channel(instance* instance, char* spec); -static int backend_set(instance* inst, size_t num, channel** c, channel_value* v); -static int backend_handle(size_t num, managed_fd* fds); -static int backend_start(); -static int backend_shutdown(); +static int osc_configure(char* option, char* value); +static int osc_configure_instance(instance* inst, char* option, char* value); +static instance* osc_instance(); +static channel* osc_map_channel(instance* inst, char* spec); +static int osc_set(instance* inst, size_t num, channel** c, channel_value* v); +static int osc_handle(size_t num, managed_fd* fds); +static int osc_start(); +static int osc_shutdown(); typedef enum { not_set = 0, @@ -52,4 +52,4 @@ typedef struct /*_osc_instance_data*/ { int fd; uint8_t learn; uint16_t forced_rport; -} osc_instance; +} osc_instance_data; |