diff options
Diffstat (limited to 'apps/mixer.c')
-rw-r--r-- | apps/mixer.c | 52 |
1 files changed, 26 insertions, 26 deletions
diff --git a/apps/mixer.c b/apps/mixer.c index 4112c6d..ef4f0fd 100644 --- a/apps/mixer.c +++ b/apps/mixer.c @@ -40,7 +40,7 @@ static void free_lang_entry(void* ptr) free(l); } -static int mixer_read_config_file(mixer_t* m, int dirfd, const char* filename) +static int mixer_read_config_file(mixer_t* x, int dirfd, const char* filename) { assert(dirfd > 0); @@ -59,7 +59,7 @@ static int mixer_read_config_file(mixer_t* m, int dirfd, const char* filename) assert(lang); assert((lang->name_ = strdup(filename))); slist_init(&(lang->cmds_), free); - assert(slist_add(&(m->langs_), lang)); + assert(slist_add(&(x->langs_), lang)); char buf[256]; while(fgets(buf, sizeof(buf), conf) != NULL) { @@ -68,7 +68,7 @@ static int mixer_read_config_file(mixer_t* m, int dirfd, const char* filename) error(0, ENOMEM, "can't create midi command stucture"); break; } - if(sscanf(buf, "%02hhx %02hhx %02hhx", &(cmd->code_[0]), &(cmd->code_[1]), &(cmd->code_[2])) != 3) { + if(sscanf(buf, "%02hhx %02hhx %02hhx", &((*cmd)[0]), &((*cmd)[1]), &((*cmd)[2])) != 3) { continue; } assert(slist_add(&(lang->cmds_), cmd)); @@ -78,10 +78,10 @@ static int mixer_read_config_file(mixer_t* m, int dirfd, const char* filename) return 0; } -static int mixer_read_config(mixer_t* m) +static int mixer_read_config(mixer_t* x) { char path[1024]; - int ret = snprintf(path, sizeof(path), "%s/%s", ETCDIR, m->name_); + int ret = snprintf(path, sizeof(path), "%s/%s", ETCDIR, x->name_); assert(ret < sizeof(path)); DIR* d = opendir(path); @@ -93,7 +93,7 @@ static int mixer_read_config(mixer_t* m) struct dirent* entry; while((entry = readdir(d))) { if(entry->d_type == DT_REG) { - if((ret = mixer_read_config_file(m, dirfd(d), entry->d_name))) + if((ret = mixer_read_config_file(x, dirfd(d), entry->d_name))) break; } } @@ -106,20 +106,20 @@ static int mixer_read_config(mixer_t* m) return ret; } -int mixer_init(mixer_t* m, const char* name, const char* device) +int mixer_init(mixer_t* x, const char* name, const char* device) { - assert(m != NULL); + assert(x != NULL); - m->name_ = name; - m->output_ = NULL; - slist_init(&(m->langs_), free_lang_entry); - int ret = snd_rawmidi_open(NULL, &(m->output_), device, SND_RAWMIDI_NONBLOCK); + x->name_ = name; + x->output_ = NULL; + slist_init(&(x->langs_), free_lang_entry); + int ret = snd_rawmidi_open(NULL, &(x->output_), device, SND_RAWMIDI_NONBLOCK); if(ret < 0) { error(0, 0, "MIXER: cannot open midi port '%s': %s", device, snd_strerror(ret)); return ret; } - return mixer_read_config(m);; + return mixer_read_config(x);; } static void mixer_print_midi_cmds(slist_t cmds) @@ -130,21 +130,21 @@ static void mixer_print_midi_cmds(slist_t cmds) slist_element_t* tmp; for(tmp = cmds.first_; tmp; tmp = tmp->next_) { midi_cmd_t* c = (midi_cmd_t*)(tmp->data_); - printf(" 0x%02X 0x%02X 0x%02X\n", c->code_[0], c->code_[1], c->code_[2]); + printf(" 0x%02X 0x%02X 0x%02X\n", (*c)[0], (*c)[1], (*c)[2]); } } } -void mixer_print_langs(mixer_t* m) +void mixer_print_langs(mixer_t* x) { - assert(m); + assert(x); printf("mixer:\n"); - if(!slist_length(&(m->langs_))) + if(!slist_length(&(x->langs_))) printf(" <no languages>\n"); else { slist_element_t* tmp; - for(tmp = m->langs_.first_; tmp; tmp = tmp->next_) { + for(tmp = x->langs_.first_; tmp; tmp = tmp->next_) { lang_t* l = (lang_t*)(tmp->data_); printf(" %s:\n", l->name_); mixer_print_midi_cmds(l->cmds_); @@ -152,21 +152,21 @@ void mixer_print_langs(mixer_t* m) } } -int mixer_get_poll_fd_count(mixer_t* m) +int mixer_get_poll_fd_count(mixer_t* x) { - return snd_rawmidi_poll_descriptors_count(m->output_); + return snd_rawmidi_poll_descriptors_count(x->output_); } -int mixer_get_poll_fds(mixer_t* m, struct pollfd *pfds, int npfds) +int mixer_get_poll_fds(mixer_t* x, struct pollfd *pfds, int npfds) { - return snd_rawmidi_poll_descriptors(m->output_, pfds, npfds); + return snd_rawmidi_poll_descriptors(x->output_, pfds, npfds); } -int mixer_handle_revents(mixer_t* m, struct pollfd *pfds, int npfds) +int mixer_handle_revents(mixer_t* x, struct pollfd *pfds, int npfds) { int err; unsigned short revents; - if((err = snd_rawmidi_poll_descriptors_revents(m->output_, pfds, npfds, &revents)) < 0) { + if((err = snd_rawmidi_poll_descriptors_revents(x->output_, pfds, npfds, &revents)) < 0) { error(0, 0, "MIXER: cannot get poll events: %s", snd_strerror(errno)); return -1; } @@ -178,7 +178,7 @@ int mixer_handle_revents(mixer_t* m, struct pollfd *pfds, int npfds) return 0; u_int8_t buf[3] = { 0xB0, 0x00, 0x02 }; - int ret = snd_rawmidi_write(m->output_, buf, sizeof(buf)); + int ret = snd_rawmidi_write(x->output_, buf, sizeof(buf)); if(ret == -EAGAIN) return 0; if(ret < 0) { @@ -186,7 +186,7 @@ int mixer_handle_revents(mixer_t* m, struct pollfd *pfds, int npfds) return -1; } assert(ret == sizeof(buf)); // TODO: try again?? - if((err = snd_rawmidi_drain(m->output_)) < 0) { + if((err = snd_rawmidi_drain(x->output_)) < 0) { error(0, 0, "MIXER: cannot drain output: %s", snd_strerror(err)); return -1; } |