From 90b5655a6eb3837ad6f984ce4ffcd3e9aa7480ce Mon Sep 17 00:00:00 2001 From: cbdev Date: Thu, 5 Mar 2020 00:03:12 +0100 Subject: Implement ArtNet rate-limiting to approx. 44 pps --- backends/artnet.h | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) (limited to 'backends/artnet.h') diff --git a/backends/artnet.h b/backends/artnet.h index 1efdee6..aac73fe 100644 --- a/backends/artnet.h +++ b/backends/artnet.h @@ -4,6 +4,7 @@ #include "midimonster.h" MM_PLUGIN_API int init(); +static uint32_t artnet_interval(); static int artnet_configure(char* option, char* value); static int artnet_configure_instance(instance* instance, char* option, char* value); static int artnet_instance(instance* inst); @@ -16,7 +17,10 @@ static int artnet_shutdown(size_t n, instance** inst); #define ARTNET_PORT "6454" #define ARTNET_VERSION 14 #define ARTNET_RECV_BUF 4096 -#define ARTNET_KEEPALIVE_INTERVAL 2000 + +#define ARTNET_KEEPALIVE_INTERVAL 1000 +//limit transmit rate to at most 44 packets per second (1000/44 ~= 22) +#define ARTNET_FRAME_TIMEOUT 20 #define MAP_COARSE 0x0200 #define MAP_FINE 0x0400 @@ -52,11 +56,16 @@ typedef union /*_artnet_instance_id*/ { uint64_t label; } artnet_instance_id; +typedef struct /*_artnet_fd_universe*/ { + uint64_t label; + uint64_t last_frame; + uint8_t mark; +} artnet_output_universe; + typedef struct /*_artnet_fd*/ { int fd; size_t output_instances; - artnet_instance_id* output_instance; - uint64_t* last_frame; + artnet_output_universe* output_instance; } artnet_descriptor; #pragma pack(push, 1) -- cgit v1.2.3