diff options
| author | Jan Düpmeier <j.duepmeier@googlemail.com> | 2017-11-07 11:49:07 +0100 | 
|---|---|---|
| committer | Jan Düpmeier <j.duepmeier@googlemail.com> | 2017-11-07 11:49:07 +0100 | 
| commit | 6ca55cd4bf67ded4f7a9fcd230f2a1860cca4dac (patch) | |
| tree | 97b7157a7b683571d33ff0af7d2c4ff03712e2e3 | |
| parent | 3d33f854c0c2c35e33c8491d3442fb5f9396f2b2 (diff) | |
| download | midimonster-6ca55cd4bf67ded4f7a9fcd230f2a1860cca4dac.tar.gz midimonster-6ca55cd4bf67ded4f7a9fcd230f2a1860cca4dac.tar.bz2 midimonster-6ca55cd4bf67ded4f7a9fcd230f2a1860cca4dac.zip | |
impl uinput shutdown
| -rw-r--r-- | uinput.c | 29 | ||||
| -rw-r--r-- | uinput.h | 2 | 
2 files changed, 30 insertions, 1 deletions
| @@ -3,6 +3,7 @@  #include <stdio.h>  #include <errno.h>  #include <string.h> +#include <unistd.h>  #include "midimonster.h"  #include "uinput.h" @@ -233,6 +234,32 @@ static int backend_set(instance* inst, size_t num, channel** c, channel_value* v  }  static int backend_shutdown() { -	//TODO impl +	uinput_instance* data = NULL; +	instance** instances = NULL; +	size_t n = 0; + +	if (mm_backend_instances(BACKEND_NAME, &n, &instances)) { +		fprintf(stderr, "Failed to fetch instance list\n"); +		return 1; +	} + +	if (!n) { +		free(instances); +		return 0; +	} + +	for (unsigned p = 0; p < n; p++) { +		data = (uinput_instance*) instances[p]->impl; +		if (data->fd_in < 0) { +			close(data->fd_in); +			data->fd_in = -1; +		} + +		if (data->fd_out < 0) { +			close(data->fd_out); +			data->fd_out = -1; +		} +	} +	free(instances);  	return 0;  } @@ -1,3 +1,5 @@ +#pragma once +  #include <sys/types.h>  #include <linux/input.h> | 
