aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorcbdev <cb@cbcdn.com>2021-07-02 02:08:26 +0200
committercbdev <cb@cbcdn.com>2021-07-02 02:08:26 +0200
commit1654245bf80013a96434cb4c60e6583ab7522f1b (patch)
tree665ade2185e5eab4f8415462db14ba5eb84777b6
parent6a3f12be67f70f07d3ae93edfd7b14c02c61f68f (diff)
downloadmidimonster-1654245bf80013a96434cb4c60e6583ab7522f1b.tar.gz
midimonster-1654245bf80013a96434cb4c60e6583ab7522f1b.tar.bz2
midimonster-1654245bf80013a96434cb4c60e6583ab7522f1b.zip
Add frontend interval API
-rw-r--r--core/backend.c10
-rw-r--r--core/backend.h3
-rw-r--r--core/core.c1
3 files changed, 12 insertions, 2 deletions
diff --git a/core/backend.c b/core/backend.c
index b7c2d9e..93ac8fa 100644
--- a/core/backend.c
+++ b/core/backend.c
@@ -9,6 +9,8 @@
#include "midimonster.h"
#include "backend.h"
+static uint32_t default_interval = 1000;
+
static struct {
size_t n;
backend* backends;
@@ -272,9 +274,15 @@ instance* instance_match(char* name){
return NULL;
}
+void mm_default_interval(uint32_t interval, uint8_t force){
+ if(interval < default_interval || force){
+ default_interval = interval;
+ }
+}
+
struct timeval backend_timeout(){
size_t u;
- uint32_t res, secs = 1, msecs = 0;
+ uint32_t res, secs = default_interval / 1000, msecs = default_interval % 1000;
for(u = 0; u < registry.n; u++){
//only call interval if backend has instances
diff --git a/core/backend.h b/core/backend.h
index 1f85424..6c1fe22 100644
--- a/core/backend.h
+++ b/core/backend.h
@@ -10,6 +10,9 @@ int backends_start();
int backends_stop();
instance* mm_instance(backend* b);
+/* Frontend API */
+void mm_default_interval(uint32_t interval, uint8_t force);
+
/* Public backend API */
MM_API channel* mm_channel(instance* inst, uint64_t ident, uint8_t create);
MM_API void mm_channel_update(channel* chan, uint64_t ident);
diff --git a/core/core.c b/core/core.c
index 2f5ca40..8554f03 100644
--- a/core/core.c
+++ b/core/core.c
@@ -20,7 +20,6 @@
#include "config.h"
static struct {
- //static size_t fds = 0;
size_t n;
int max;
managed_fd* fd;