aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2020-03-23 01:30:14 +0100
committercbdev <cb@cbcdn.com>2020-03-23 01:30:14 +0100
commite8d87602618b4a9fab056f1d03b87c706d5f1f9f (patch)
tree727f49ad571b8d1859bf984b85594207b131060d
parent37e712edf23a49be5387f945ab9ea57cc0b57f22 (diff)
downloadmidimonster-e8d87602618b4a9fab056f1d03b87c706d5f1f9f.tar.gz
midimonster-e8d87602618b4a9fab056f1d03b87c706d5f1f9f.tar.bz2
midimonster-e8d87602618b4a9fab056f1d03b87c706d5f1f9f.zip
Update rtpmidi to current API
-rw-r--r--backends/Makefile2
-rw-r--r--backends/rtpmidi.c23
-rw-r--r--backends/rtpmidi.h2
3 files changed, 8 insertions, 19 deletions
diff --git a/backends/Makefile b/backends/Makefile
index 8956a20..c19d9dd 100644
--- a/backends/Makefile
+++ b/backends/Makefile
@@ -1,7 +1,7 @@
.PHONY: all clean full
LINUX_BACKENDS = midi.so evdev.so
WINDOWS_BACKENDS = artnet.dll osc.dll loopback.dll sacn.dll maweb.dll winmidi.dll openpixelcontrol.dll rtpmidi.dll
-BACKENDS = artnet.so osc.so loopback.so sacn.so lua.so maweb.so jack.so openpixelcontrol.so python.so rtpmidi.dll
+BACKENDS = artnet.so osc.so loopback.so sacn.so lua.so maweb.so jack.so openpixelcontrol.so python.so rtpmidi.so
OPTIONAL_BACKENDS = ola.so
BACKEND_LIB = libmmbackend.o
diff --git a/backends/rtpmidi.c b/backends/rtpmidi.c
index c39139a..2eec871 100644
--- a/backends/rtpmidi.c
+++ b/backends/rtpmidi.c
@@ -357,24 +357,17 @@ static int rtpmidi_configure_instance(instance* inst, char* option, char* value)
return 1;
}
-static instance* rtpmidi_instance(){
- rtpmidi_instance_data* data = NULL;
- instance* inst = mm_instance();
-
- if(!inst){
- return NULL;
- }
-
- data = calloc(1, sizeof(rtpmidi_instance_data));
+static int rtpmidi_instance(instance* inst){
+ rtpmidi_instance_data* data = calloc(1, sizeof(rtpmidi_instance_data));
if(!data){
LOG("Failed to allocate memory");
- return NULL;
+ return 1;
}
data->fd = -1;
data->control_fd = -1;
inst->impl = data;
- return inst;
+ return 0;
}
static channel* rtpmidi_channel(instance* inst, char* spec, uint8_t flags){
@@ -910,7 +903,7 @@ static int rtpmidi_service(){
memcpy(&control_peer, &(data->peer[u].dest), sizeof(control_peer));
((struct sockaddr_in*) &control_peer)->sin_port = be16toh(htobe16(((struct sockaddr_in*) &control_peer)->sin_port) - 1);
- sendto(data->control_fd, &sync, sizeof(apple_sync_frame), 0, (struct sockaddr*) &control_peer, data->peer[u].dest_len);
+ sendto(data->control_fd, (char*) &sync, sizeof(apple_sync_frame), 0, (struct sockaddr*) &control_peer, data->peer[u].dest_len);
}
else if(data->peer[p].active && !data->peer[p].learned && (mm_timestamp() / 1000) % 10 == 0){
//try to invite pre-defined unconnected applemidi peers
@@ -922,7 +915,7 @@ static int rtpmidi_service(){
//append session name to packet
memcpy(frame + sizeof(apple_command), data->session_name ? data->session_name : RTPMIDI_DEFAULT_NAME, strlen((data->session_name ? data->session_name : RTPMIDI_DEFAULT_NAME)) + 1);
- sendto(data->control_fd, invite, sizeof(apple_command) + strlen((data->session_name ? data->session_name : RTPMIDI_DEFAULT_NAME)) + 1, 0, (struct sockaddr*) &control_peer, data->peer[u].dest_len);
+ sendto(data->control_fd, (char*) invite, sizeof(apple_command) + strlen((data->session_name ? data->session_name : RTPMIDI_DEFAULT_NAME)) + 1, 0, (struct sockaddr*) &control_peer, data->peer[u].dest_len);
}
}
}
@@ -947,10 +940,6 @@ static int rtpmidi_handle(size_t num, managed_fd* fds){
cfg.last_service = mm_timestamp();
}
- if(!num){
- return 0;
- }
-
for(u = 0; u < num; u++){
if(!fds[u].impl){
//TODO handle mDNS discovery input
diff --git a/backends/rtpmidi.h b/backends/rtpmidi.h
index db6237b..a08cf0f 100644
--- a/backends/rtpmidi.h
+++ b/backends/rtpmidi.h
@@ -6,7 +6,7 @@
MM_PLUGIN_API int init();
static int rtpmidi_configure(char* option, char* value);
static int rtpmidi_configure_instance(instance* instance, char* option, char* value);
-static instance* rtpmidi_instance();
+static int rtpmidi_instance(instance* inst);
static channel* rtpmidi_channel(instance* instance, char* spec, uint8_t flags);
static int rtpmidi_set(instance* inst, size_t num, channel** c, channel_value* v);
static int rtpmidi_handle(size_t num, managed_fd* fds);