aboutsummaryrefslogtreecommitdiffhomepage
path: root/backends/evdev.c
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2019-12-11 23:24:23 +0100
committercbdev <cb@cbcdn.com>2019-12-11 23:24:23 +0100
commit9624d46436576b415c639ea7390012cdd95c88f7 (patch)
treefb3aadbaf01fcee5da8ecdb8355ff191341b666d /backends/evdev.c
parent48e12201f5c57cda581bc0c713d99da6524c49a8 (diff)
parentf6d6eefe9bb9934f4fa3e665734d746f02471cdb (diff)
downloadmidimonster-9624d46436576b415c639ea7390012cdd95c88f7.tar.gz
midimonster-9624d46436576b415c639ea7390012cdd95c88f7.tar.bz2
midimonster-9624d46436576b415c639ea7390012cdd95c88f7.zip
Merge branch 'master' into rtpmidi
Diffstat (limited to 'backends/evdev.c')
-rw-r--r--backends/evdev.c31
1 files changed, 5 insertions, 26 deletions
diff --git a/backends/evdev.c b/backends/evdev.c
index 0da5ae6..d2eeba8 100644
--- a/backends/evdev.c
+++ b/backends/evdev.c
@@ -393,21 +393,10 @@ static int evdev_handle(size_t num, managed_fd* fds){
return 0;
}
-static int evdev_start(){
- size_t n, u, fds = 0;
- instance** inst = NULL;
+static int evdev_start(size_t n, instance** inst){
+ size_t u, fds = 0;
evdev_instance_data* data = NULL;
- if(mm_backend_instances(BACKEND_NAME, &n, &inst)){
- fprintf(stderr, "Failed to fetch instance list\n");
- return 1;
- }
-
- if(!n){
- free(inst);
- return 0;
- }
-
for(u = 0; u < n; u++){
data = (evdev_instance_data*) inst[u]->impl;
@@ -415,7 +404,6 @@ static int evdev_start(){
if(data->output_enabled){
if(libevdev_uinput_create_from_device(data->output_proto, LIBEVDEV_UINPUT_OPEN_MANAGED, &data->output_ev)){
fprintf(stderr, "Failed to create evdev output device: %s\n", strerror(errno));
- free(inst);
return 1;
}
fprintf(stderr, "Created device node %s for instance %s\n", libevdev_uinput_get_devnode(data->output_ev), inst[u]->name);
@@ -426,7 +414,6 @@ static int evdev_start(){
if(data->input_fd >= 0){
if(mm_manage_fd(data->input_fd, BACKEND_NAME, 1, inst[u])){
fprintf(stderr, "Failed to register event input descriptor for instance %s\n", inst[u]->name);
- free(inst);
return 1;
}
fds++;
@@ -439,7 +426,6 @@ static int evdev_start(){
}
fprintf(stderr, "evdev backend registered %zu descriptors to core\n", fds);
- free(inst);
return 0;
}
@@ -512,18 +498,12 @@ static int evdev_set(instance* inst, size_t num, channel** c, channel_value* v)
#endif
}
-static int evdev_shutdown(){
+static int evdev_shutdown(size_t n, instance** inst){
evdev_instance_data* data = NULL;
- instance** instances = NULL;
- size_t n, u;
-
- if(mm_backend_instances(BACKEND_NAME, &n, &instances)){
- fprintf(stderr, "Failed to fetch instance list\n");
- return 1;
- }
+ size_t u;
for(u = 0; u < n; u++){
- data = (evdev_instance_data*) instances[u]->impl;
+ data = (evdev_instance_data*) inst[u]->impl;
if(data->input_fd >= 0){
libevdev_free(data->input_ev);
@@ -542,7 +522,6 @@ static int evdev_shutdown(){
free(data);
}
- free(instances);
fprintf(stderr, "evdev backend shut down\n");
return 0;
}