aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--backends/artnet.c2
-rw-r--r--backends/artnet.h2
-rw-r--r--backends/evdev.c2
-rw-r--r--backends/evdev.h2
-rw-r--r--backends/jack.c2
-rw-r--r--backends/jack.h2
-rw-r--r--backends/loopback.c2
-rw-r--r--backends/loopback.h2
-rw-r--r--backends/lua.c2
-rw-r--r--backends/lua.h2
-rw-r--r--backends/maweb.c2
-rw-r--r--backends/maweb.h2
-rw-r--r--backends/midi.c2
-rw-r--r--backends/midi.h2
-rw-r--r--backends/ola.cpp2
-rw-r--r--backends/ola.h2
-rw-r--r--backends/osc.c2
-rw-r--r--backends/osc.h2
-rw-r--r--backends/sacn.c2
-rw-r--r--backends/sacn.h2
-rw-r--r--backends/winmidi.c2
-rw-r--r--backends/winmidi.h2
-rw-r--r--config.c8
-rw-r--r--midimonster.h15
24 files changed, 38 insertions, 29 deletions
diff --git a/backends/artnet.c b/backends/artnet.c
index 8a62a43..57eb7b1 100644
--- a/backends/artnet.c
+++ b/backends/artnet.c
@@ -156,7 +156,7 @@ static int artnet_configure_instance(instance* inst, char* option, char* value){
return 1;
}
-static channel* artnet_channel(instance* inst, char* spec){
+static channel* artnet_channel(instance* inst, char* spec, uint8_t flags){
artnet_instance_data* data = (artnet_instance_data*) inst->impl;
char* spec_next = spec;
unsigned chan_a = strtoul(spec, &spec_next, 10);
diff --git a/backends/artnet.h b/backends/artnet.h
index cce11d1..f6a6709 100644
--- a/backends/artnet.h
+++ b/backends/artnet.h
@@ -7,7 +7,7 @@ MM_PLUGIN_API int init();
static int artnet_configure(char* option, char* value);
static int artnet_configure_instance(instance* instance, char* option, char* value);
static instance* artnet_instance();
-static channel* artnet_channel(instance* instance, char* spec);
+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();
diff --git a/backends/evdev.c b/backends/evdev.c
index dd2231b..0da5ae6 100644
--- a/backends/evdev.c
+++ b/backends/evdev.c
@@ -249,7 +249,7 @@ static int evdev_configure_instance(instance* inst, char* option, char* value) {
return 1;
}
-static channel* evdev_channel(instance* inst, char* spec){
+static channel* evdev_channel(instance* inst, char* spec, uint8_t flags){
#ifndef EVDEV_NO_UINPUT
evdev_instance_data* data = (evdev_instance_data*) inst->impl;
#endif
diff --git a/backends/evdev.h b/backends/evdev.h
index 30ce892..6504416 100644
--- a/backends/evdev.h
+++ b/backends/evdev.h
@@ -12,7 +12,7 @@ MM_PLUGIN_API int init();
static int evdev_configure(char* option, char* value);
static int evdev_configure_instance(instance* instance, char* option, char* value);
static instance* evdev_instance();
-static channel* evdev_channel(instance* instance, char* spec);
+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();
diff --git a/backends/jack.c b/backends/jack.c
index 926f800..e7bed04 100644
--- a/backends/jack.c
+++ b/backends/jack.c
@@ -409,7 +409,7 @@ static int mmjack_parse_midispec(mmjack_channel_ident* ident, char* spec){
return 0;
}
-static channel* mmjack_channel(instance* inst, char* spec){
+static channel* mmjack_channel(instance* inst, char* spec, uint8_t flags){
mmjack_instance_data* data = (mmjack_instance_data*) inst->impl;
mmjack_channel_ident ident = {
.label = 0
diff --git a/backends/jack.h b/backends/jack.h
index 5598042..a7f3e8b 100644
--- a/backends/jack.h
+++ b/backends/jack.h
@@ -6,7 +6,7 @@ MM_PLUGIN_API int init();
static int mmjack_configure(char* option, char* value);
static int mmjack_configure_instance(instance* inst, char* option, char* value);
static instance* mmjack_instance();
-static channel* mmjack_channel(instance* inst, char* spec);
+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();
diff --git a/backends/loopback.c b/backends/loopback.c
index 0a45bde..41e6f85 100644
--- a/backends/loopback.c
+++ b/backends/loopback.c
@@ -49,7 +49,7 @@ static instance* loopback_instance(){
return i;
}
-static channel* loopback_channel(instance* inst, char* spec){
+static channel* loopback_channel(instance* inst, char* spec, uint8_t flags){
size_t u;
loopback_instance_data* data = (loopback_instance_data*) inst->impl;
diff --git a/backends/loopback.h b/backends/loopback.h
index a08417b..ee51c66 100644
--- a/backends/loopback.h
+++ b/backends/loopback.h
@@ -4,7 +4,7 @@ MM_PLUGIN_API int init();
static int loopback_configure(char* option, char* value);
static int loopback_configure_instance(instance* inst, char* option, char* value);
static instance* loopback_instance();
-static channel* loopback_channel(instance* inst, char* spec);
+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();
diff --git a/backends/lua.c b/backends/lua.c
index 0b47b2c..40e6613 100644
--- a/backends/lua.c
+++ b/backends/lua.c
@@ -330,7 +330,7 @@ static instance* lua_instance(){
return inst;
}
-static channel* lua_channel(instance* inst, char* spec){
+static channel* lua_channel(instance* inst, char* spec, uint8_t flags){
size_t u;
lua_instance_data* data = (lua_instance_data*) inst->impl;
diff --git a/backends/lua.h b/backends/lua.h
index e187a8e..4ea5b0a 100644
--- a/backends/lua.h
+++ b/backends/lua.h
@@ -13,7 +13,7 @@ MM_PLUGIN_API int init();
static int lua_configure(char* option, char* value);
static int lua_configure_instance(instance* inst, char* option, char* value);
static instance* lua_instance();
-static channel* lua_channel(instance* inst, char* spec);
+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();
diff --git a/backends/maweb.c b/backends/maweb.c
index 08156f2..d008cc0 100644
--- a/backends/maweb.c
+++ b/backends/maweb.c
@@ -229,7 +229,7 @@ static instance* maweb_instance(){
return inst;
}
-static channel* maweb_channel(instance* inst, char* spec){
+static channel* maweb_channel(instance* inst, char* spec, uint8_t flags){
maweb_instance_data* data = (maweb_instance_data*) inst->impl;
maweb_channel_data chan = {
0
diff --git a/backends/maweb.h b/backends/maweb.h
index 9091cda..05095f8 100644
--- a/backends/maweb.h
+++ b/backends/maweb.h
@@ -4,7 +4,7 @@ MM_PLUGIN_API int init();
static int maweb_configure(char* option, char* value);
static int maweb_configure_instance(instance* inst, char* option, char* value);
static instance* maweb_instance();
-static channel* maweb_channel(instance* inst, char* spec);
+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();
diff --git a/backends/midi.c b/backends/midi.c
index f380f59..92776ca 100644
--- a/backends/midi.c
+++ b/backends/midi.c
@@ -110,7 +110,7 @@ static int midi_configure_instance(instance* inst, char* option, char* value){
return 1;
}
-static channel* midi_channel(instance* inst, char* spec){
+static channel* midi_channel(instance* inst, char* spec, uint8_t flags){
midi_channel_ident ident = {
.label = 0
};
diff --git a/backends/midi.h b/backends/midi.h
index b9934f1..4e16f90 100644
--- a/backends/midi.h
+++ b/backends/midi.h
@@ -4,7 +4,7 @@ MM_PLUGIN_API int init();
static int midi_configure(char* option, char* value);
static int midi_configure_instance(instance* instance, char* option, char* value);
static instance* midi_instance();
-static channel* midi_channel(instance* instance, char* spec);
+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();
diff --git a/backends/ola.cpp b/backends/ola.cpp
index d069a8c..c13e8f9 100644
--- a/backends/ola.cpp
+++ b/backends/ola.cpp
@@ -68,7 +68,7 @@ static int ola_configure_instance(instance* inst, char* option, char* value){
return 1;
}
-static channel* ola_channel(instance* inst, char* spec){
+static channel* ola_channel(instance* inst, char* spec, uint8_t flags){
ola_instance_data* data = (ola_instance_data*) inst->impl;
char* spec_next = spec;
unsigned chan_a = strtoul(spec, &spec_next, 10);
diff --git a/backends/ola.h b/backends/ola.h
index 1637495..0c42bac 100644
--- a/backends/ola.h
+++ b/backends/ola.h
@@ -8,7 +8,7 @@ extern "C" {
static int ola_configure(char* option, char* value);
static int ola_configure_instance(instance* instance, char* option, char* value);
static instance* ola_instance();
- static channel* ola_channel(instance* instance, char* spec);
+ static channel* ola_channel(instance* instance, char* spec, uint8_t flags);
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();
diff --git a/backends/osc.c b/backends/osc.c
index d9f9139..757ad89 100644
--- a/backends/osc.c
+++ b/backends/osc.c
@@ -577,7 +577,7 @@ static instance* osc_instance(){
return inst;
}
-static channel* osc_map_channel(instance* inst, char* spec){
+static channel* osc_map_channel(instance* inst, char* spec, uint8_t flags){
size_t u, p;
osc_instance_data* data = (osc_instance_data*) inst->impl;
osc_channel_ident ident = {
diff --git a/backends/osc.h b/backends/osc.h
index 86be285..6f3b923 100644
--- a/backends/osc.h
+++ b/backends/osc.h
@@ -11,7 +11,7 @@ MM_PLUGIN_API int init();
static int osc_configure(char* option, char* value);
static int osc_configure_instance(instance* inst, char* option, char* value);
static instance* osc_instance();
-static channel* osc_map_channel(instance* inst, char* spec);
+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();
diff --git a/backends/sacn.c b/backends/sacn.c
index d8b3eb3..2229b8a 100644
--- a/backends/sacn.c
+++ b/backends/sacn.c
@@ -198,7 +198,7 @@ static instance* sacn_instance(){
return inst;
}
-static channel* sacn_channel(instance* inst, char* spec){
+static channel* sacn_channel(instance* inst, char* spec, uint8_t flags){
sacn_instance_data* data = (sacn_instance_data*) inst->impl;
char* spec_next = spec;
diff --git a/backends/sacn.h b/backends/sacn.h
index 631d3a4..1d3268c 100644
--- a/backends/sacn.h
+++ b/backends/sacn.h
@@ -4,7 +4,7 @@ MM_PLUGIN_API int init();
static int sacn_configure(char* option, char* value);
static int sacn_configure_instance(instance* instance, char* option, char* value);
static instance* sacn_instance();
-static channel* sacn_channel(instance* instance, char* spec);
+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();
diff --git a/backends/winmidi.c b/backends/winmidi.c
index b274c06..790257b 100644
--- a/backends/winmidi.c
+++ b/backends/winmidi.c
@@ -110,7 +110,7 @@ static instance* winmidi_instance(){
return i;
}
-static channel* winmidi_channel(instance* inst, char* spec){
+static channel* winmidi_channel(instance* inst, char* spec, uint8_t flags){
char* next_token = NULL;
winmidi_channel_ident ident = {
.label = 0
diff --git a/backends/winmidi.h b/backends/winmidi.h
index 8c2d76b..985c46a 100644
--- a/backends/winmidi.h
+++ b/backends/winmidi.h
@@ -4,7 +4,7 @@ MM_PLUGIN_API int init();
static int winmidi_configure(char* option, char* value);
static int winmidi_configure_instance(instance* inst, char* option, char* value);
static instance* winmidi_instance();
-static channel* winmidi_channel(instance* inst, char* spec);
+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();
diff --git a/config.c b/config.c
index 8e7e581..0b9173e 100644
--- a/config.c
+++ b/config.c
@@ -175,7 +175,7 @@ static int config_glob_scan(instance* inst, channel_spec* spec){
return 0;
}
-static channel* config_glob_resolve(instance* inst, channel_spec* spec, uint64_t n){
+static channel* config_glob_resolve(instance* inst, channel_spec* spec, uint64_t n, uint8_t map_direction){
size_t glob = 0, glob_length;
ssize_t bytes = 0;
uint64_t current_value = 0;
@@ -216,7 +216,7 @@ static channel* config_glob_resolve(instance* inst, channel_spec* spec, uint64_t
}
}
- result = inst->backend->channel(inst, resolved_spec);
+ result = inst->backend->channel(inst, resolved_spec, map_direction);
if(spec->globs && !result){
fprintf(stderr, "Failed to match multichannel evaluation %s to a channel\n", resolved_spec);
}
@@ -294,8 +294,8 @@ static int config_map(char* to_raw, char* from_raw){
//iterate, resolve globs and map
rv = 0;
for(n = 0; !rv && n < max(spec_from.channels, spec_to.channels); n++){
- channel_from = config_glob_resolve(instance_from, &spec_from, min(n, spec_from.channels));
- channel_to = config_glob_resolve(instance_to, &spec_to, min(n, spec_to.channels));
+ channel_from = config_glob_resolve(instance_from, &spec_from, min(n, spec_from.channels), mmchannel_input);
+ channel_to = config_glob_resolve(instance_to, &spec_to, min(n, spec_to.channels), mmchannel_output);
if(!channel_from || !channel_to){
rv = 1;
diff --git a/midimonster.h b/midimonster.h
index 1192d6a..5ce0c73 100644
--- a/midimonster.h
+++ b/midimonster.h
@@ -87,8 +87,11 @@ struct _managed_fd;
* Parse instance configuration from the user-supplied configuration
* file. Returning a non-zero value fails config parsing.
* * mmbackend_channel
- * Parse a channel-spec to be mapped to/from. Returning NULL signals an
- * out-of-memory condition and terminates the program.
+ * Parse a channel-spec to be mapped to/from. The `falgs` parameter supplies
+ * additional information to the parser, such as whether the channel is being
+ * queried for use as input (to the MIDIMonster core) and/or output
+ * (from the MIDIMonster core) channel (on a per-query basis).
+ * Returning NULL signals an out-of-memory condition and terminates the program.
* * mmbackend_start
* Called after all instances have been created and all mappings
* have been set up. Only backends for which instances have been configured
@@ -121,7 +124,7 @@ struct _managed_fd;
*/
typedef int (*mmbackend_handle_event)(struct _backend_instance* inst, size_t channels, struct _backend_channel** c, struct _channel_value* v);
typedef struct _backend_instance* (*mmbackend_create_instance)();
-typedef struct _backend_channel* (*mmbackend_parse_channel)(struct _backend_instance* instance, char* spec);
+typedef struct _backend_channel* (*mmbackend_parse_channel)(struct _backend_instance* instance, char* spec, uint8_t flags);
typedef void (*mmbackend_free_channel)(struct _backend_channel* c);
typedef int (*mmbackend_configure)(char* option, char* value);
typedef int (*mmbackend_configure_instance)(struct _backend_instance* instance, char* option, char* value);
@@ -130,6 +133,12 @@ typedef int (*mmbackend_start)();
typedef uint32_t (*mmbackend_interval)();
typedef int (*mmbackend_shutdown)();
+/* Bit masks for the `flags` parameter to mmbackend_parse_channel */
+typedef enum {
+ mmchannel_input = 0x1,
+ mmchannel_output = 0x2
+} mmbe_channel_flags;
+
/* Channel event value, .normalised is used by backends to determine channel values */
typedef struct _channel_value {
union {