aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2019-12-08 02:27:04 +0100
committercbdev <cb@cbcdn.com>2019-12-08 02:27:04 +0100
commit99d31eabf4a3afa4fd54782cc1d7cd92fbdae084 (patch)
treea8b30197c71dfea551d7adb6a6cee53cd94fd200
parent588f204eaa6c69a8f09a70d9188cefcb6c6075f6 (diff)
downloadmidimonster-99d31eabf4a3afa4fd54782cc1d7cd92fbdae084.tar.gz
midimonster-99d31eabf4a3afa4fd54782cc1d7cd92fbdae084.tar.bz2
midimonster-99d31eabf4a3afa4fd54782cc1d7cd92fbdae084.zip
Cleanup rtmidi data structures
-rw-r--r--backends/rtpmidi.c13
-rw-r--r--backends/rtpmidi.h28
-rw-r--r--backends/rtpmidi.md5
3 files changed, 19 insertions, 27 deletions
diff --git a/backends/rtpmidi.c b/backends/rtpmidi.c
index 5387d86..ea97565 100644
--- a/backends/rtpmidi.c
+++ b/backends/rtpmidi.c
@@ -7,6 +7,7 @@
#include <fcntl.h>
#include <ctype.h>
+#include "libmmbackend.h"
#include "rtpmidi.h"
#define BACKEND_NAME "rtpmidi"
@@ -65,7 +66,9 @@ static int rtpmidi_configure(char* option, char* value){
return 1;
}
- if(mmbackend_parse_hostspec(value, &host, &port)){
+ mmbackend_parse_hostspec(value, &host, &port);
+
+ if(!host){
fprintf(stderr, "Not a valid mDNS bind address: %s\n", value);
return 1;
}
@@ -164,13 +167,5 @@ static int rtpmidi_shutdown(){
close(cfg.mdns_fd);
}
- for(u = 0; u < cfg.nfds; u++){
- if(cfg.fds[u].data >= 0){
- close(cfg.fds[u].data);
- }
- if(cfg.fds[u].control >= 0){
- close(cfg.fds[u].control);
- }
- }
return 0;
}
diff --git a/backends/rtpmidi.h b/backends/rtpmidi.h
index 6985ede..af6a189 100644
--- a/backends/rtpmidi.h
+++ b/backends/rtpmidi.h
@@ -14,31 +14,27 @@ static int rtpmidi_shutdown();
#define RTPMIDI_DEFAULT_PORTBASE "9001"
#define RTPMIDI_RECV_BUF 4096
#define RTPMIDI_MDNS_PORT "5353"
+#define RTPMIDI_HEADER_MAGIC htobe16(0x80E1)
-typedef enum /*_rtpmidi_peer_mode*/ {
- peer_learned,
- peer_invited,
- peer_invited_by,
- peer_sync,
- peer_connect
-} rtpmidi_peer_mode;
+typedef enum /*_rtpmidi_instance_mode*/ {
+ direct,
+ apple
+} rtpmidi_instance_mode;
typedef struct /*_rtpmidi_peer*/ {
- rtpmidi_peer_mode mode;
struct sockaddr_storage dest;
socklen_t dest_len;
uint32_t ssrc;
} rtpmidi_peer;
-typedef struct /*_rtpmidi_fd*/ {
- int data;
- int control;
-} rtpmidi_fd;
-
typedef struct /*_rtmidi_instance_data*/ {
+ rtpmidi_instance_mode mode;
+
int fd;
- size_t npeers;
- rtpmidi_peer* peers;
+ int control_fd;
+
+ size_t peers;
+ rtpmidi_peer* peer;
uint32_t ssrc;
//apple-midi config
@@ -46,7 +42,7 @@ typedef struct /*_rtmidi_instance_data*/ {
char* invite_peers;
char* invite_accept;
- //generic mode config
+ //direct mode config
uint8_t learn_peers;
} rtpmidi_instance_data;
diff --git a/backends/rtpmidi.md b/backends/rtpmidi.md
index 49c6baf..cea69e2 100644
--- a/backends/rtpmidi.md
+++ b/backends/rtpmidi.md
@@ -49,10 +49,11 @@ Common instance configuration parameters
|---------------|-----------------------|-----------------------|-----------------------|
| `bind` | `10.1.2.1 9001` | `0.0.0.0 <random>` | Local network address to bind to (note that AppleMIDI requires two consecutive port numbers to be allocated) |
| `session` | `Just Jamming` | `MIDIMonster` | Session name to announce via mDNS |
-| `invite` | `pad,piano` | none | Devices to send invitations to when discovered (the special value `*` invites all discovered peers) |
+| `invite` | `pad,piano` | none | Devices to send invitations to when discovered (the special value `*` invites all discovered peers). Setting this option makes the instance a session initiator |
+| `joint` | `Just Jamming` | none | Sessions for which to accept invitations (the special value `*` accepts all invitations). Setting this option makes the instance a session participant |
Note that AppleMIDI session establishment requires mDNS functionality, thus the `mdns-name` global parameter
-(and, depending on your setup, the `mdns-bind` parameter) need to be configured properly.
+(and, depending on your setup, the `mdns-bind` parameter) need to be configured properly.
#### Channel specification