aboutsummaryrefslogtreecommitdiffhomepage
path: root/midimonster.c
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2018-02-28 17:05:56 +0100
committercbdev <cb@cbcdn.com>2018-02-28 17:05:56 +0100
commit2477edba0ae270a337f284ac7862d172f66a0303 (patch)
treee03418eb4127e796a13910686e4309669e247b00 /midimonster.c
parenta16094253ba19f2e7123029eb80fba52b0d192b6 (diff)
downloadmidimonster-2477edba0ae270a337f284ac7862d172f66a0303.tar.gz
midimonster-2477edba0ae270a337f284ac7862d172f66a0303.tar.bz2
midimonster-2477edba0ae270a337f284ac7862d172f66a0303.zip
Update ArtNet configuration syntax, add mm_timestamp API
Diffstat (limited to 'midimonster.c')
-rw-r--r--midimonster.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/midimonster.c b/midimonster.c
index eb5510c..87abfb1 100644
--- a/midimonster.c
+++ b/midimonster.c
@@ -3,6 +3,7 @@
#include <sys/select.h>
#include <unistd.h>
#include <errno.h>
+#include <time.h>
#include "midimonster.h"
#include "config.h"
#include "backend.h"
@@ -19,6 +20,7 @@ static size_t mappings = 0;
static channel_mapping* map = NULL;
static size_t fds = 0;
static managed_fd* fd = NULL;
+static uint64_t global_timestamp = 0;
static event_collection event_pool[2] = {
{0},
@@ -28,10 +30,24 @@ static event_collection* primary = event_pool;
volatile static sig_atomic_t shutdown_requested = 0;
-void signal_handler(int signum){
+static void signal_handler(int signum){
shutdown_requested = 1;
}
+uint64_t mm_timestamp(){
+ return global_timestamp;
+}
+
+static void update_timestamp(){
+ struct timespec current;
+ if(clock_gettime(CLOCK_MONOTONIC_COARSE, &current)){
+ fprintf(stderr, "Failed to update global timestamp, time-based processing for some backends may be impaired: %s\n", strerror(errno));
+ return;
+ }
+
+ global_timestamp = current.tv_sec * 1000 + current.tv_nsec / 1000000;
+}
+
int mm_map_channel(channel* from, channel* to){
size_t u, m;
//find existing source mapping
@@ -277,6 +293,9 @@ int main(int argc, char** argv){
}
}
+ //update this iteration's timestamp
+ update_timestamp();
+
//run backend processing, collect events
DBGPF("%zu backend FDs signaled\n", n);
if(backends_handle(n, signaled_fds)){