aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
-rw-r--r--TODO5
-rw-r--r--backends/artnet.c8
-rw-r--r--backends/maweb.c34
-rw-r--r--backends/osc.c24
-rw-r--r--backends/sacn.c10
-rw-r--r--config.c6
-rw-r--r--midimonster.h1
-rw-r--r--portability.h4
8 files changed, 51 insertions, 41 deletions
diff --git a/TODO b/TODO
index d04773b..cba1c15 100644
--- a/TODO
+++ b/TODO
@@ -1,10 +1,13 @@
+winmidi
+rename
+release
+
MIDI NRPN
keepalive channels per backend?
mm_backend_start might get some arguments so they don't have to fetch them all the time
mm_channel_resolver might get additional info about the mapping direction
Note source in channel value struct
Optimize core channel search (store backend offset)
-Printing backend / Verbose mode
mm_managed_fd.impl is not freed currently
diff --git a/backends/artnet.c b/backends/artnet.c
index 8e47d4f..e01ac94 100644
--- a/backends/artnet.c
+++ b/backends/artnet.c
@@ -32,7 +32,7 @@ static int artnet_listener(char* host, char* port){
return -1;
}
- fprintf(stderr, "ArtNet backend interface %lu bound to %s port %s\n", artnet_fds, host, port);
+ fprintf(stderr, "ArtNet backend interface %" PRIsize_t " bound to %s port %s\n", artnet_fds, host, port);
artnet_fd[artnet_fds].fd = fd;
artnet_fd[artnet_fds].output_instances = 0;
artnet_fd[artnet_fds].output_instance = NULL;
@@ -235,7 +235,7 @@ static int artnet_set(instance* inst, size_t num, channel** c, channel_value* v)
artnet_instance_data* data = (artnet_instance_data*) inst->impl;
if(!data->dest_len){
- fprintf(stderr, "ArtNet instance %s not enabled for output (%lu channel events)\n", inst->name, num);
+ fprintf(stderr, "ArtNet instance %s not enabled for output (%" PRIsize_t " channel events)\n", inst->name, num);
return 0;
}
@@ -300,7 +300,7 @@ static inline int artnet_process_frame(instance* inst, artnet_pkt* frame){
}
if(!chan){
- fprintf(stderr, "Active channel %lu on %s not known to core\n", p, inst->name);
+ fprintf(stderr, "Active channel %" PRIsize_t " on %s not known to core\n", p, inst->name);
return 1;
}
@@ -447,7 +447,7 @@ static int artnet_start(){
}
}
- fprintf(stderr, "ArtNet backend registering %lu descriptors to core\n", artnet_fds);
+ fprintf(stderr, "ArtNet backend registering %" PRIsize_t " descriptors to core\n", artnet_fds);
for(u = 0; u < artnet_fds; u++){
if(mm_manage_fd(artnet_fd[u].fd, BACKEND_NAME, 1, (void*) u)){
goto bail;
diff --git a/backends/maweb.c b/backends/maweb.c
index 80ab579..8d39f00 100644
--- a/backends/maweb.c
+++ b/backends/maweb.c
@@ -5,6 +5,8 @@
#include <openssl/md5.h>
#endif
+#define DEBUG
+
#include "libmmbackend.h"
#include "maweb.h"
@@ -338,7 +340,7 @@ static int maweb_process_playback(instance* inst, int64_t page, maweb_channel_ty
//ignore unused buttons
return 0;
}
- fprintf(stderr, "maweb missing exec block data on exec %ld.%d\n", page, ident.fields.index);
+ fprintf(stderr, "maweb missing exec block data on exec %" PRIu64 ".%d\n", page, ident.fields.index);
return 1;
}
@@ -367,7 +369,7 @@ static int maweb_process_playback(instance* inst, int64_t page, maweb_channel_ty
mm_channel_event(chan, evt);
}
- DBGPF("maweb page %ld exec %d value %f running %lu\n", page, ident.fields.index, json_obj_double(payload + control, "v", 0.0), json_obj_int(payload, "isRun", 0));
+ DBGPF("maweb page %" PRIu64 " exec %d value %f running %" PRIu64 "\n", page, ident.fields.index, json_obj_double(payload + control, "v", 0.0), json_obj_int(payload, "isRun", 0));
ident.fields.index++;
block++;
}
@@ -420,7 +422,7 @@ static int maweb_process_playbacks(instance* inst, int64_t page, char* payload,
group++;
}
updates_inflight--;
- DBGPF("maweb playback message processing done, %lu updates inflight\n", updates_inflight);
+ DBGPF("maweb playback message processing done, %" PRIu64 " updates inflight\n", updates_inflight);
return 0;
}
@@ -433,7 +435,7 @@ static int maweb_request_playbacks(instance* inst){
size_t page_index = 0, view = 3, channel = 0, offsets[3], channel_offset, channels;
if(updates_inflight){
- fprintf(stderr, "maweb skipping update request, %lu updates still inflight\n", updates_inflight);
+ fprintf(stderr, "maweb skipping update request, %" PRIu64 " updates still inflight\n", updates_inflight);
return 0;
}
@@ -476,7 +478,7 @@ static int maweb_request_playbacks(instance* inst){
else{
//for the ma, the view equals the exec type requested (we can query all button execs from button view, all fader execs from fader view)
view = (data->input_channel[channel].fields.index >= 100) ? 3 : 2;
- snprintf(item_types, sizeof(item_types), "[%lu]", view);
+ snprintf(item_types, sizeof(item_types), "[%" PRIsize_t "]", view);
//this channel must be included, so it must be in range for the first startindex
snprintf(item_indices, sizeof(item_indices), "[%d]", (data->input_channel[channel].fields.index / 5) * 5);
@@ -487,7 +489,7 @@ static int maweb_request_playbacks(instance* inst){
channels = data->input_channel[channel + channel_offset - 1].fields.index - (data->input_channel[channel].fields.index / 5) * 5;
- snprintf(item_counts, sizeof(item_indices), "[%lu]", ((channels / 5) * 5 + 5));
+ snprintf(item_counts, sizeof(item_indices), "[%" PRIsize_t "]", ((channels / 5) * 5 + 5));
}
//advance base channel
@@ -499,12 +501,12 @@ static int maweb_request_playbacks(instance* inst){
"\"requestType\":\"playbacks\","
"\"startIndex\":%s,"
"\"itemsCount\":%s,"
- "\"pageIndex\":%lu,"
+ "\"pageIndex\":%" PRIsize_t ","
"\"itemsType\":%s,"
- "\"view\":%lu,"
+ "\"view\":%" PRIsize_t ","
"\"execButtonViewMode\":2," //extended
"\"buttonsViewMode\":0," //get vfader for button execs
- "\"session\":%lu"
+ "\"session\":%" PRIu64
"}",
item_indices,
item_counts,
@@ -546,16 +548,16 @@ static int maweb_handle_message(instance* inst, char* payload, size_t payload_le
}
}
- DBGPF("maweb message (%lu): %s\n", payload_length, payload);
+ DBGPF("maweb message (%" PRIsize_t "): %s\n", payload_length, payload);
if(json_obj(payload, "session") == JSON_NUMBER){
data->session = json_obj_int(payload, "session", data->session);
- fprintf(stderr, "maweb session id is now %ld\n", data->session);
+ fprintf(stderr, "maweb session id is now %" PRIu64 "\n", data->session);
}
if(json_obj_bool(payload, "forceLogin", 0)){
fprintf(stderr, "maweb sending user credentials\n");
snprintf(xmit_buffer, sizeof(xmit_buffer),
- "{\"requestType\":\"login\",\"username\":\"%s\",\"password\":\"%s\",\"session\":%ld}",
+ "{\"requestType\":\"login\",\"username\":\"%s\",\"password\":\"%s\",\"session\":%" PRIu64 "}",
(data->peer_type == peer_dot2) ? "remote" : data->user, data->pass, data->session);
maweb_send_frame(inst, ws_text, (uint8_t*) xmit_buffer, strlen(xmit_buffer));
}
@@ -787,7 +789,7 @@ static int maweb_set(instance* inst, size_t num, channel** c, channel_value* v){
"\"pageIndex\":%d,"
"\"faderValue\":%f,"
"\"type\":1,"
- "\"session\":%ld"
+ "\"session\":%" PRIu64
"}", ident.fields.index, ident.fields.page, v[n].normalised, data->session);
maweb_send_frame(inst, ws_text, (uint8_t*) xmit_buffer, strlen(xmit_buffer));
break;
@@ -803,7 +805,7 @@ static int maweb_set(instance* inst, size_t num, channel** c, channel_value* v){
"\"pressed\":%s,"
"\"released\":%s,"
"\"type\":0,"
- "\"session\":%ld"
+ "\"session\":%" PRIu64
"}", ident.fields.index, ident.fields.page,
(data->peer_type == peer_dot2 && ident.fields.type == exec_upper) ? 0 : (ident.fields.type - exec_button),
(v[n].normalised > 0.9) ? "true" : "false",
@@ -844,7 +846,7 @@ static int maweb_keepalive(){
for(u = 0; u < n; u++){
data = (maweb_instance_data*) inst[u]->impl;
if(data->login){
- snprintf(xmit_buffer, sizeof(xmit_buffer), "{\"session\":%ld}", data->session);
+ snprintf(xmit_buffer, sizeof(xmit_buffer), "{\"session\":%" PRIu64 "}", data->session);
maweb_send_frame(inst[u], ws_text, (uint8_t*) xmit_buffer, strlen(xmit_buffer));
}
}
@@ -926,7 +928,7 @@ static int maweb_start(){
return 0;
}
- fprintf(stderr, "maweb backend registering %lu descriptors to core\n", n);
+ fprintf(stderr, "maweb backend registering %" PRIsize_t " descriptors to core\n", n);
//initialize timeouts
last_keepalive = last_update = mm_timestamp();
diff --git a/backends/osc.c b/backends/osc.c
index beb5527..bffbba8 100644
--- a/backends/osc.c
+++ b/backends/osc.c
@@ -239,20 +239,20 @@ static int osc_path_validate(char* path, uint8_t allow_patterns){
for(u = 0; u < strlen(path); u++){
for(c = 0; c < sizeof(illegal_chars); c++){
if(path[u] == illegal_chars[c]){
- fprintf(stderr, "%s is not a valid OSC path: Illegal '%c' at %lu\n", path, illegal_chars[c], u);
+ fprintf(stderr, "%s is not a valid OSC path: Illegal '%c' at %" PRIsize_t "\n", path, illegal_chars[c], u);
return 1;
}
}
if(!isgraph(path[u])){
- fprintf(stderr, "%s is not a valid OSC path: Illegal '%c' at %lu\n", path, pattern_chars[c], u);
+ fprintf(stderr, "%s is not a valid OSC path: Illegal '%c' at %" PRIsize_t "\n", path, pattern_chars[c], u);
return 1;
}
if(!allow_patterns){
for(c = 0; c < sizeof(pattern_chars); c++){
if(path[u] == pattern_chars[c]){
- fprintf(stderr, "%s is not a valid OSC path: Illegal '%c' at %lu\n", path, pattern_chars[c], u);
+ fprintf(stderr, "%s is not a valid OSC path: Illegal '%c' at %" PRIsize_t "\n", path, pattern_chars[c], u);
return 1;
}
}
@@ -261,14 +261,14 @@ static int osc_path_validate(char* path, uint8_t allow_patterns){
switch(path[u]){
case '{':
if(square_open || curly_open){
- fprintf(stderr, "%s is not a valid OSC path: Illegal '%c' at %lu\n", path, pattern_chars[c], u);
+ fprintf(stderr, "%s is not a valid OSC path: Illegal '%c' at %" PRIsize_t "\n", path, pattern_chars[c], u);
return 1;
}
curly_open = 1;
break;
case '[':
if(square_open || curly_open){
- fprintf(stderr, "%s is not a valid OSC path: Illegal '%c' at %lu\n", path, pattern_chars[c], u);
+ fprintf(stderr, "%s is not a valid OSC path: Illegal '%c' at %" PRIsize_t "\n", path, pattern_chars[c], u);
return 1;
}
square_open = 1;
@@ -477,14 +477,14 @@ static int osc_register_pattern(osc_instance_data* data, char* pattern_path, cha
//parse min/max values
token = strtok(NULL, " ");
if(!token){
- fprintf(stderr, "Missing minimum specification for parameter %lu of OSC pattern %s\n", u, pattern_path);
+ fprintf(stderr, "Missing minimum specification for parameter %" PRIsize_t " of OSC pattern %s\n", u, pattern_path);
return 1;
}
data->pattern[pattern].min[u] = osc_parse_value_spec(format[u], token);
token = strtok(NULL, " ");
if(!token){
- fprintf(stderr, "Missing maximum specification for parameter %lu of OSC pattern %s\n", u, pattern_path);
+ fprintf(stderr, "Missing maximum specification for parameter %" PRIsize_t " of OSC pattern %s\n", u, pattern_path);
return 1;
}
data->pattern[pattern].max[u] = osc_parse_value_spec(format[u], token);
@@ -686,7 +686,7 @@ static int osc_output_channel(instance* inst, size_t channel){
//write data
if(offset + osc_data_length(data->channel[channel].type[p]) >= sizeof(xmit_buf)){
- fprintf(stderr, "Insufficient buffer size for OSC transmitting channel %s.%s at parameter %lu\n", inst->name, data->channel[channel].path, p);
+ fprintf(stderr, "Insufficient buffer size for OSC transmitting channel %s.%s at parameter %" PRIsize_t "\n", inst->name, data->channel[channel].path, p);
return 1;
}
@@ -717,7 +717,7 @@ static int osc_set(instance* inst, size_t num, channel** c, channel_value* v){
osc_instance_data* data = (osc_instance_data*) inst->impl;
if(!data->dest_len){
- fprintf(stderr, "OSC instance %s does not have a destination, output is disabled (%lu channels)\n", inst->name, num);
+ fprintf(stderr, "OSC instance %s does not have a destination, output is disabled (%" PRIsize_t " channels)\n", inst->name, num);
return 0;
}
@@ -775,7 +775,7 @@ static int osc_process_packet(instance* inst, char* local_path, char* format, ui
channel* chan = NULL;
if(payload_len % 4){
- fprintf(stderr, "Invalid OSC packet, data length %lu\n", payload_len);
+ fprintf(stderr, "Invalid OSC packet, data length %" PRIsize_t "\n", payload_len);
return 0;
}
@@ -784,7 +784,7 @@ static int osc_process_packet(instance* inst, char* local_path, char* format, ui
ident.fields.channel = c;
//unconfigured input should work without errors (using default limits)
if(data->channel[c].params && strlen(format) != data->channel[c].params){
- fprintf(stderr, "OSC message %s.%s had format %s, internal representation has %lu parameters\n", inst->name, local_path, format, data->channel[c].params);
+ fprintf(stderr, "OSC message %s.%s had format %s, internal representation has %" PRIsize_t " parameters\n", inst->name, local_path, format, data->channel[c].params);
continue;
}
@@ -925,7 +925,7 @@ static int osc_start(){
}
}
- fprintf(stderr, "OSC backend registered %lu descriptors to core\n", fds);
+ fprintf(stderr, "OSC backend registered %" PRIsize_t " descriptors to core\n", fds);
free(inst);
return 0;
diff --git a/backends/sacn.c b/backends/sacn.c
index 470e3bd..6e1b20b 100644
--- a/backends/sacn.c
+++ b/backends/sacn.c
@@ -78,7 +78,7 @@ static int sacn_listener(char* host, char* port, uint8_t fd_flags){
return -1;
}
- fprintf(stderr, "sACN backend interface %lu bound to %s port %s\n", global_cfg.fds, host, port);
+ fprintf(stderr, "sACN backend interface %" PRIsize_t " bound to %s port %s\n", global_cfg.fds, host, port);
global_cfg.fd[global_cfg.fds].fd = fd;
global_cfg.fd[global_cfg.fds].flags = fd_flags;
global_cfg.fd[global_cfg.fds].universes = 0;
@@ -300,7 +300,7 @@ static int sacn_set(instance* inst, size_t num, channel** c, channel_value* v){
}
if(!data->xmit_prio){
- fprintf(stderr, "sACN instance %s not enabled for output (%lu channel events)\n", inst->name, num);
+ fprintf(stderr, "sACN instance %s not enabled for output (%" PRIsize_t " channel events)\n", inst->name, num);
return 0;
}
@@ -385,7 +385,7 @@ static int sacn_process_frame(instance* inst, sacn_frame_root* frame, sacn_frame
}
if(!chan){
- fprintf(stderr, "Active channel %lu on %s not known to core", u, inst->name);
+ fprintf(stderr, "Active channel %" PRIsize_t " on %s not known to core", u, inst->name);
return 1;
}
@@ -453,7 +453,7 @@ static void sacn_discovery(size_t fd){
memcpy(pdu.data.data, global_cfg.fd[fd].universe + page * 512, universes * sizeof(uint16_t));
if(sendto(global_cfg.fd[fd].fd, (uint8_t*) &pdu, sizeof(pdu) - (512 - universes) * sizeof(uint16_t), 0, (struct sockaddr*) &discovery_dest, sizeof(discovery_dest)) < 0){
- fprintf(stderr, "Failed to output sACN universe discovery frame for interface %lu: %s\n", fd, strerror(errno));
+ fprintf(stderr, "Failed to output sACN universe discovery frame for interface %" PRIsize_t ": %s\n", fd, strerror(errno));
}
}
}
@@ -615,7 +615,7 @@ static int sacn_start(){
}
}
- fprintf(stderr, "sACN backend registering %lu descriptors to core\n", global_cfg.fds);
+ fprintf(stderr, "sACN backend registering %" PRIsize_t " descriptors to core\n", global_cfg.fds);
for(u = 0; u < global_cfg.fds; u++){
//allocate memory for storing last frame transmission timestamp
global_cfg.fd[u].last_frame = calloc(global_cfg.fd[u].universes, sizeof(uint64_t));
diff --git a/config.c b/config.c
index 93fb56d..f4d928e 100644
--- a/config.c
+++ b/config.c
@@ -162,7 +162,7 @@ static int config_glob_scan(instance* inst, channel_spec* spec){
}
if(!spec->internal){
//TODO try to parse globs externally
- fprintf(stderr, "Failed to parse glob %lu in %s internally\n", u + 1, spec->spec);
+ fprintf(stderr, "Failed to parse glob %" PRIsize_t " in %s internally\n", u + 1, spec->spec);
return 1;
}
@@ -199,7 +199,7 @@ static channel* config_glob_resolve(instance* inst, channel_spec* spec, uint64_t
//write out value
bytes = snprintf(resolved_spec + spec->glob[glob - 1].offset[0],
glob_length,
- "%lu",
+ "%" PRIu64,
current_value);
if(bytes > glob_length){
fprintf(stderr, "Internal error resolving glob %s\n", spec->spec);
@@ -279,7 +279,7 @@ static int config_map(char* to_raw, char* from_raw){
if((spec_to.channels != spec_from.channels && spec_from.channels != 1 && spec_to.channels != 1)
|| spec_to.channels == 0
|| spec_from.channels == 0){
- fprintf(stderr, "Multi-channel specification size mismatch: %s.%s (%lu channels) - %s.%s (%lu channels)\n",
+ fprintf(stderr, "Multi-channel specification size mismatch: %s.%s (%" PRIsize_t " channels) - %s.%s (%" PRIsize_t " channels)\n",
instance_from->name,
spec_from.spec,
spec_from.channels,
diff --git a/midimonster.h b/midimonster.h
index 270a61f..491cc11 100644
--- a/midimonster.h
+++ b/midimonster.h
@@ -3,6 +3,7 @@
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
+#include <inttypes.h>
#ifndef MM_API
#ifdef _WIN32
diff --git a/portability.h b/portability.h
index 903ecd8..f0bfd07 100644
--- a/portability.h
+++ b/portability.h
@@ -35,4 +35,8 @@
#define htole64(x) (x)
#define be64toh(x) _byteswap_uint64(x)
#define le64toh(x) (x)
+
+ #define PRIsize_t "Iu"
+#else
+ #define PRIsize_t "zu"
#endif