aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorJan Düpmeier <j.duepmeier@googlemail.com>2017-11-07 11:49:07 +0100
committerJan Düpmeier <j.duepmeier@googlemail.com>2017-11-07 11:49:07 +0100
commit6ca55cd4bf67ded4f7a9fcd230f2a1860cca4dac (patch)
tree97b7157a7b683571d33ff0af7d2c4ff03712e2e3
parent3d33f854c0c2c35e33c8491d3442fb5f9396f2b2 (diff)
downloadmidimonster-6ca55cd4bf67ded4f7a9fcd230f2a1860cca4dac.tar.gz
midimonster-6ca55cd4bf67ded4f7a9fcd230f2a1860cca4dac.tar.bz2
midimonster-6ca55cd4bf67ded4f7a9fcd230f2a1860cca4dac.zip
impl uinput shutdown
-rw-r--r--uinput.c29
-rw-r--r--uinput.h2
2 files changed, 30 insertions, 1 deletions
diff --git a/uinput.c b/uinput.c
index 25d6c70..b9396c2 100644
--- a/uinput.c
+++ b/uinput.c
@@ -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;
}
diff --git a/uinput.h b/uinput.h
index 8c4925a..035696d 100644
--- a/uinput.h
+++ b/uinput.h
@@ -1,3 +1,5 @@
+#pragma once
+
#include <sys/types.h>
#include <linux/input.h>