aboutsummaryrefslogtreecommitdiffhomepage
path: root/backends
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2019-12-11 23:20:34 +0100
committercbdev <cb@cbcdn.com>2019-12-11 23:20:34 +0100
commitf6d6eefe9bb9934f4fa3e665734d746f02471cdb (patch)
tree4f177149cd7a39ba0214b0edf337362c7ead3234 /backends
parentf65fb8baaba285f5ff4b02af111420ba4479f5d9 (diff)
downloadmidimonster-f6d6eefe9bb9934f4fa3e665734d746f02471cdb.tar.gz
midimonster-f6d6eefe9bb9934f4fa3e665734d746f02471cdb.tar.bz2
midimonster-f6d6eefe9bb9934f4fa3e665734d746f02471cdb.zip
Simplify plugin_stop API
Diffstat (limited to 'backends')
-rw-r--r--backends/artnet.c10
-rw-r--r--backends/artnet.h2
-rw-r--r--backends/evdev.c13
-rw-r--r--backends/evdev.h2
-rw-r--r--backends/jack.c12
-rw-r--r--backends/jack.h2
-rw-r--r--backends/loopback.c12
-rw-r--r--backends/loopback.h2
-rw-r--r--backends/lua.c12
-rw-r--r--backends/lua.h2
-rw-r--r--backends/maweb.c13
-rw-r--r--backends/maweb.h4
-rw-r--r--backends/midi.c10
-rw-r--r--backends/midi.h2
-rw-r--r--backends/ola.cpp16
-rw-r--r--backends/ola.h2
-rw-r--r--backends/osc.c11
-rw-r--r--backends/osc.h2
-rw-r--r--backends/sacn.c11
-rw-r--r--backends/sacn.h2
-rw-r--r--backends/winmidi.c11
-rw-r--r--backends/winmidi.h2
22 files changed, 35 insertions, 120 deletions
diff --git a/backends/artnet.c b/backends/artnet.c
index e4147ec..b181296 100644
--- a/backends/artnet.c
+++ b/backends/artnet.c
@@ -438,18 +438,12 @@ bail:
return rv;
}
-static int artnet_shutdown(){
- size_t n, p;
- instance** inst = NULL;
- if(mm_backend_instances(BACKEND_NAME, &n, &inst)){
- fprintf(stderr, "Failed to fetch instance list\n");
- return 1;
- }
+static int artnet_shutdown(size_t n, instance** inst){
+ size_t p;
for(p = 0; p < n; p++){
free(inst[p]->impl);
}
- free(inst);
for(p = 0; p < artnet_fds; p++){
close(artnet_fd[p].fd);
diff --git a/backends/artnet.h b/backends/artnet.h
index 738b55c..59bd53f 100644
--- a/backends/artnet.h
+++ b/backends/artnet.h
@@ -11,7 +11,7 @@ static channel* artnet_channel(instance* instance, char* spec, uint8_t flags);
static int artnet_set(instance* inst, size_t num, channel** c, channel_value* v);
static int artnet_handle(size_t num, managed_fd* fds);
static int artnet_start(size_t n, instance** inst);
-static int artnet_shutdown();
+static int artnet_shutdown(size_t n, instance** inst);
#define ARTNET_PORT "6454"
#define ARTNET_VERSION 14
diff --git a/backends/evdev.c b/backends/evdev.c
index 9998a03..d2eeba8 100644
--- a/backends/evdev.c
+++ b/backends/evdev.c
@@ -498,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);
@@ -528,7 +522,6 @@ static int evdev_shutdown(){
free(data);
}
- free(instances);
fprintf(stderr, "evdev backend shut down\n");
return 0;
}
diff --git a/backends/evdev.h b/backends/evdev.h
index 1f03941..0c877fc 100644
--- a/backends/evdev.h
+++ b/backends/evdev.h
@@ -16,7 +16,7 @@ static channel* evdev_channel(instance* instance, char* spec, uint8_t flags);
static int evdev_set(instance* inst, size_t num, channel** c, channel_value* v);
static int evdev_handle(size_t num, managed_fd* fds);
static int evdev_start(size_t n, instance** inst);
-static int evdev_shutdown();
+static int evdev_shutdown(size_t n, instance** inst);
#define INPUT_NODES "/dev/input"
#define INPUT_PREFIX "event"
diff --git a/backends/jack.c b/backends/jack.c
index 047dce8..eb53190 100644
--- a/backends/jack.c
+++ b/backends/jack.c
@@ -685,16 +685,10 @@ bail:
return rv;
}
-static int mmjack_shutdown(){
- size_t n, u, p;
- instance** inst = NULL;
+static int mmjack_shutdown(size_t n, instance** inst){
+ size_t u, p;
mmjack_instance_data* data = NULL;
- if(mm_backend_instances(BACKEND_NAME, &n, &inst)){
- fprintf(stderr, "Failed to fetch instance list\n");
- return 1;
- }
-
for(u = 0; u < n; u++){
data = (mmjack_instance_data*) inst[u]->impl;
@@ -733,8 +727,6 @@ static int mmjack_shutdown(){
data->fd = -1;
}
- free(inst);
-
fprintf(stderr, "jack backend shut down\n");
return 0;
}
diff --git a/backends/jack.h b/backends/jack.h
index c9f8c4c..66c66db 100644
--- a/backends/jack.h
+++ b/backends/jack.h
@@ -10,7 +10,7 @@ static channel* mmjack_channel(instance* inst, char* spec, uint8_t flags);
static int mmjack_set(instance* inst, size_t num, channel** c, channel_value* v);
static int mmjack_handle(size_t num, managed_fd* fds);
static int mmjack_start(size_t n, instance** inst);
-static int mmjack_shutdown();
+static int mmjack_shutdown(size_t n, instance** inst);
#define JACK_DEFAULT_CLIENT_NAME "MIDIMonster"
#define JACK_DEFAULT_SERVER_NAME "default"
diff --git a/backends/loopback.c b/backends/loopback.c
index 616eccf..c2c3430 100644
--- a/backends/loopback.c
+++ b/backends/loopback.c
@@ -96,16 +96,10 @@ static int loopback_start(size_t n, instance** inst){
return 0;
}
-static int loopback_shutdown(){
- size_t n, u, p;
- instance** inst = NULL;
+static int loopback_shutdown(size_t n, instance** inst){
+ size_t u, p;
loopback_instance_data* data = NULL;
- if(mm_backend_instances(BACKEND_NAME, &n, &inst)){
- fprintf(stderr, "Failed to fetch instance list\n");
- return 1;
- }
-
for(u = 0; u < n; u++){
data = (loopback_instance_data*) inst[u]->impl;
for(p = 0; p < data->n; p++){
@@ -115,8 +109,6 @@ static int loopback_shutdown(){
free(inst[u]->impl);
}
- free(inst);
-
fprintf(stderr, "Loopback backend shut down\n");
return 0;
}
diff --git a/backends/loopback.h b/backends/loopback.h
index dee3e9d..c508d72 100644
--- a/backends/loopback.h
+++ b/backends/loopback.h
@@ -8,7 +8,7 @@ static channel* loopback_channel(instance* inst, char* spec, uint8_t flags);
static int loopback_set(instance* inst, size_t num, channel** c, channel_value* v);
static int loopback_handle(size_t num, managed_fd* fds);
static int loopback_start(size_t n, instance** inst);
-static int loopback_shutdown();
+static int loopback_shutdown(size_t n, instance** inst);
typedef struct /*_loopback_instance_data*/ {
size_t n;
diff --git a/backends/lua.c b/backends/lua.c
index b165dd8..2ce40f5 100644
--- a/backends/lua.c
+++ b/backends/lua.c
@@ -460,17 +460,10 @@ static int lua_start(size_t n, instance** inst){
return 0;
}
-static int lua_shutdown(){
- size_t n, u, p;
- instance** inst = NULL;
+static int lua_shutdown(size_t n, instance** inst){
+ size_t u, p;
lua_instance_data* data = NULL;
- //fetch all instances
- if(mm_backend_instances(BACKEND_NAME, &n, &inst)){
- fprintf(stderr, "Failed to fetch instance list\n");
- return 1;
- }
-
for(u = 0; u < n; u++){
data = (lua_instance_data*) inst[u]->impl;
//stop the interpreter
@@ -486,7 +479,6 @@ static int lua_shutdown(){
free(inst[u]->impl);
}
- free(inst);
//free module-global data
free(timer);
timer = NULL;
diff --git a/backends/lua.h b/backends/lua.h
index 9e19506..75f03c4 100644
--- a/backends/lua.h
+++ b/backends/lua.h
@@ -17,7 +17,7 @@ static channel* lua_channel(instance* inst, char* spec, uint8_t flags);
static int lua_set(instance* inst, size_t num, channel** c, channel_value* v);
static int lua_handle(size_t num, managed_fd* fds);
static int lua_start(size_t n, instance** inst);
-static int lua_shutdown();
+static int lua_shutdown(size_t n, instance** inst);
#ifndef MMBACKEND_LUA_TIMERFD
static uint32_t lua_interval();
#endif
diff --git a/backends/maweb.c b/backends/maweb.c
index 28cad0c..8cf201e 100644
--- a/backends/maweb.c
+++ b/backends/maweb.c
@@ -1017,17 +1017,10 @@ static int maweb_start(size_t n, instance** inst){
return 0;
}
-static int maweb_shutdown(){
- size_t n, u;
- instance** inst = NULL;
+static int maweb_shutdown(size_t n, instance** inst){
+ size_t u;
maweb_instance_data* data = NULL;
- //fetch all instances
- if(mm_backend_instances(BACKEND_NAME, &n, &inst)){
- fprintf(stderr, "Failed to fetch instance list\n");
- return 1;
- }
-
for(u = 0; u < n; u++){
data = (maweb_instance_data*) inst[u]->impl;
free(data->host);
@@ -1053,8 +1046,6 @@ static int maweb_shutdown(){
data->channels = 0;
}
- free(inst);
-
fprintf(stderr, "maweb backend shut down\n");
return 0;
}
diff --git a/backends/maweb.h b/backends/maweb.h
index 05095f8..50b777a 100644
--- a/backends/maweb.h
+++ b/backends/maweb.h
@@ -7,8 +7,8 @@ static instance* maweb_instance();
static channel* maweb_channel(instance* inst, char* spec, uint8_t flags);
static int maweb_set(instance* inst, size_t num, channel** c, channel_value* v);
static int maweb_handle(size_t num, managed_fd* fds);
-static int maweb_start();
-static int maweb_shutdown();
+static int maweb_start(size_t n, instance** inst);
+static int maweb_shutdown(size_t n, instance** inst);
static uint32_t maweb_interval();
//Default login password: MD5("midimonster")
diff --git a/backends/midi.c b/backends/midi.c
index a7945ec..2088774 100644
--- a/backends/midi.c
+++ b/backends/midi.c
@@ -415,14 +415,9 @@ bail:
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;
@@ -432,7 +427,6 @@ static int midi_shutdown(){
data->write = NULL;
free(inst[p]->impl);
}
- free(inst);
//close midi
if(sequencer){
diff --git a/backends/midi.h b/backends/midi.h
index 579c9cb..66a02bc 100644
--- a/backends/midi.h
+++ b/backends/midi.h
@@ -8,7 +8,7 @@ static channel* midi_channel(instance* instance, char* spec, uint8_t flags);
static int midi_set(instance* inst, size_t num, channel** c, channel_value* v);
static int midi_handle(size_t num, managed_fd* fds);
static int midi_start(size_t n, instance** inst);
-static int midi_shutdown();
+static int midi_shutdown(size_t n, instance** inst);
typedef struct /*_midi_instance_data*/ {
int port;
diff --git a/backends/ola.cpp b/backends/ola.cpp
index 088c20c..fd121a0 100644
--- a/backends/ola.cpp
+++ b/backends/ola.cpp
@@ -248,12 +248,6 @@ static int ola_start(size_t n, instance** inst){
ola_client->SetDmxCallback(ola::NewCallback(&ola_data_receive));
- //fetch all defined instances
- if(mm_backend_instances(BACKEND_NAME, &n, &inst)){
- fprintf(stderr, "Failed to fetch instance list\n");
- goto bail;
- }
-
for(u = 0; u < n; u++){
data = (ola_instance_data*) inst[u]->impl;
inst[u]->ident = data->universe_id;
@@ -279,18 +273,12 @@ bail:
return 1;
}
-static int ola_shutdown(){
- size_t n, p;
- instance** inst = NULL;
- if(mm_backend_instances(BACKEND_NAME, &n, &inst)){
- fprintf(stderr, "Failed to fetch instance list\n");
- return 1;
- }
+static int ola_shutdown(size_t n, instance** inst){
+ size_t p;
for(p = 0; p < n; p++){
free(inst[p]->impl);
}
- free(inst);
if(ola_client){
ola_client->Stop();
diff --git a/backends/ola.h b/backends/ola.h
index 2a55b77..083e971 100644
--- a/backends/ola.h
+++ b/backends/ola.h
@@ -12,7 +12,7 @@ extern "C" {
static int ola_set(instance* inst, size_t num, channel** c, channel_value* v);
static int ola_handle(size_t num, managed_fd* fds);
static int ola_start(size_t n, instance** inst);
- static int ola_shutdown();
+ static int ola_shutdown(size_t n, instance** inst);
}
#define MAP_COARSE 0x0200
diff --git a/backends/osc.c b/backends/osc.c
index 61ae872..2c65ecb 100644
--- a/backends/osc.c
+++ b/backends/osc.c
@@ -917,16 +917,10 @@ static int osc_start(size_t n, instance** inst){
return 0;
}
-static int osc_shutdown(){
- size_t n, u, c;
- instance** inst = NULL;
+static int osc_shutdown(size_t n, instance** inst){
+ size_t u, c;
osc_instance_data* data = NULL;
- if(mm_backend_instances(BACKEND_NAME, &n, &inst)){
- fprintf(stderr, "Failed to fetch instance list\n");
- return 1;
- }
-
for(u = 0; u < n; u++){
data = (osc_instance_data*) inst[u]->impl;
for(c = 0; c < data->channels; c++){
@@ -953,7 +947,6 @@ static int osc_shutdown(){
free(inst[u]->impl);
}
- free(inst);
fprintf(stderr, "OSC backend shut down\n");
return 0;
}
diff --git a/backends/osc.h b/backends/osc.h
index 24cc7e5..f8ff3ff 100644
--- a/backends/osc.h
+++ b/backends/osc.h
@@ -15,7 +15,7 @@ static channel* osc_map_channel(instance* inst, char* spec, uint8_t flags);
static int osc_set(instance* inst, size_t num, channel** c, channel_value* v);
static int osc_handle(size_t num, managed_fd* fds);
static int osc_start(size_t n, instance** inst);
-static int osc_shutdown();
+static int osc_shutdown(size_t n, instance** inst);
typedef enum {
not_set = 0,
diff --git a/backends/sacn.c b/backends/sacn.c
index 877cbb0..ef422e8 100644
--- a/backends/sacn.c
+++ b/backends/sacn.c
@@ -616,19 +616,12 @@ bail:
return rv;
}
-static int sacn_shutdown(){
- size_t n, p;
- instance** inst = NULL;
-
- if(mm_backend_instances(BACKEND_NAME, &n, &inst)){
- fprintf(stderr, "Failed to fetch instance list\n");
- return 1;
- }
+static int sacn_shutdown(size_t n, instance** inst){
+ size_t p;
for(p = 0; p < n; p++){
free(inst[p]->impl);
}
- free(inst);
for(p = 0; p < global_cfg.fds; p++){
close(global_cfg.fd[p].fd);
diff --git a/backends/sacn.h b/backends/sacn.h
index 0d234d4..726fa68 100644
--- a/backends/sacn.h
+++ b/backends/sacn.h
@@ -8,7 +8,7 @@ static channel* sacn_channel(instance* instance, char* spec, uint8_t flags);
static int sacn_set(instance* inst, size_t num, channel** c, channel_value* v);
static int sacn_handle(size_t num, managed_fd* fds);
static int sacn_start(size_t n, instance** inst);
-static int sacn_shutdown();
+static int sacn_shutdown(size_t n, instance** inst);
#define SACN_PORT "5568"
#define SACN_RECV_BUF 8192
diff --git a/backends/winmidi.c b/backends/winmidi.c
index 0fc1aca..090e438 100644
--- a/backends/winmidi.c
+++ b/backends/winmidi.c
@@ -542,16 +542,10 @@ bail:
return rv;
}
-static int winmidi_shutdown(){
- size_t n, u;
- instance** inst = NULL;
+static int winmidi_shutdown(size_t n, instance** inst){
+ size_t u;
winmidi_instance_data* data = NULL;
- if(mm_backend_instances(BACKEND_NAME, &n, &inst)){
- fprintf(stderr, "Failed to fetch instance list\n");
- return 1;
- }
-
for(u = 0; u < n; u++){
data = (winmidi_instance_data*) inst[u]->impl;
free(data->read);
@@ -572,7 +566,6 @@ static int winmidi_shutdown(){
}
}
- free(inst);
closesocket(backend_config.socket_pair[0]);
closesocket(backend_config.socket_pair[1]);
diff --git a/backends/winmidi.h b/backends/winmidi.h
index 7907a42..81e7439 100644
--- a/backends/winmidi.h
+++ b/backends/winmidi.h
@@ -8,7 +8,7 @@ static channel* winmidi_channel(instance* inst, char* spec, uint8_t flags);
static int winmidi_set(instance* inst, size_t num, channel** c, channel_value* v);
static int winmidi_handle(size_t num, managed_fd* fds);
static int winmidi_start(size_t n, instance** inst);
-static int winmidi_shutdown();
+static int winmidi_shutdown(size_t n, instance** inst);
typedef struct /*_winmidi_instance_data*/ {
char* read;