diff options
Diffstat (limited to 'backends/midi.c')
-rw-r--r-- | backends/midi.c | 27 |
1 files changed, 4 insertions, 23 deletions
diff --git a/backends/midi.c b/backends/midi.c index 92776ca..2088774 100644 --- a/backends/midi.c +++ b/backends/midi.c @@ -338,25 +338,13 @@ static int midi_handle(size_t num, managed_fd* fds){ return 0; } -static int midi_start(){ - size_t n = 0, p; +static int midi_start(size_t n, instance** inst){ + size_t p; int nfds, rv = 1; struct pollfd* pfds = NULL; - instance** inst = NULL; midi_instance_data* data = NULL; snd_seq_addr_t addr; - if(mm_backend_instances(BACKEND_NAME, &n, &inst)){ - fprintf(stderr, "Failed to fetch instance list\n"); - return 1; - } - - //if there are no ports, do nothing - if(!n){ - free(inst); - return 0; - } - //connect to the sequencer if(snd_seq_open(&sequencer, "default", SND_SEQ_OPEN_DUPLEX, 0) < 0){ fprintf(stderr, "Failed to open ALSA sequencer\n"); @@ -424,18 +412,12 @@ static int midi_start(){ bail: free(pfds); - free(inst); return rv; } -static int midi_shutdown(){ - size_t n, p; - instance** inst = NULL; +static int midi_shutdown(size_t n, instance** inst){ + size_t p; midi_instance_data* data = NULL; - if(mm_backend_instances(BACKEND_NAME, &n, &inst)){ - fprintf(stderr, "Failed to fetch instance list\n"); - return 1; - } for(p = 0; p < n; p++){ data = (midi_instance_data*) inst[p]->impl; @@ -445,7 +427,6 @@ static int midi_shutdown(){ data->write = NULL; free(inst[p]->impl); } - free(inst); //close midi if(sequencer){ |