aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorSpacelord <spacelord09@users.noreply.github.com>2020-03-08 21:08:53 +0100
committerSpacelord <spacelord09@users.noreply.github.com>2020-03-08 21:08:53 +0100
commit2cffce783bcc4f34f6a609bf446530f350be04a2 (patch)
treedfe6c476a3c271b4d3a770db66bc55c9b42a62a5
parent26d661fa01df5cb2569432413ad91df891d088f2 (diff)
parent5f4b349aff49be0a5f6895631a93c47fcafcff93 (diff)
downloadmidimonster-2cffce783bcc4f34f6a609bf446530f350be04a2.tar.gz
midimonster-2cffce783bcc4f34f6a609bf446530f350be04a2.tar.bz2
midimonster-2cffce783bcc4f34f6a609bf446530f350be04a2.zip
Merge branches 'master' and 'master' of github.com:cbdevnet/midimonster
-rw-r--r--backends/lua.c6
-rw-r--r--backends/python.md8
-rw-r--r--midimonster.c11
3 files changed, 20 insertions, 5 deletions
diff --git a/backends/lua.c b/backends/lua.c
index 9a8091e..e7ba9f9 100644
--- a/backends/lua.c
+++ b/backends/lua.c
@@ -64,6 +64,7 @@ static uint32_t lua_interval(){
next_timer = timer[n].interval - timer[n].delta;
}
}
+ DBGPF("Next timer fires in %" PRIu32, next_timer);
return next_timer;
}
return 1000;
@@ -85,6 +86,7 @@ static int lua_update_timerfd(){
interval = timer[n].interval;
}
}
+ DBGPF("Recalculating timers, minimum is %" PRIu64, interval);
//calculate gcd of all timers if any are active
if(interval){
@@ -111,11 +113,13 @@ static int lua_update_timerfd(){
}
if(interval == timer_interval){
+ DBGPF("Keeping interval at %" PRIu64, interval);
return 0;
}
#ifdef MMBACKEND_LUA_TIMERFD
- //configure the new interval
+ //configure the new interval, 0.0 disarms the timer
+ DBGPF("Reconfiguring timerfd to %" PRIu64 ".%" PRIu64, timer_config.it_interval.tv_sec, timer_config.it_interval.tv_nsec);
timerfd_settime(timer_fd, 0, &timer_config, NULL);
#endif
timer_interval = interval;
diff --git a/backends/python.md b/backends/python.md
index b6a1162..f06e504 100644
--- a/backends/python.md
+++ b/backends/python.md
@@ -25,11 +25,11 @@ The `midimonster` module provides the following functions:
| `manage(function, socket)` | `midimonster.manage(handler, socket)`| Register a (connected/listening) socket to the MIDIMonster core. Calls `function(socket)` when the socket is ready to read. Calling this method with `None` as the function argument unregisters the socket. A socket may only have one associated handler |
Example Python module:
-```
+```python
import socket
import midimonster
-# Simple channel ahndler
+# Simple channel handler
def in1(value):
midimonster.output("out1", 1 - value)
@@ -45,14 +45,14 @@ def socket_handler(sock):
# Interval handler
def ping():
- print(midimonster.interval())
+ print(midimonster.timestamp())
# Register an interval
midimonster.interval(ping, 1000)
# Create and register a client socket (add error handling as you like)
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect(("localhost", 8990))
-midimonster.manage(reader, s)
+midimonster.manage(socket_handler, s)
```
Input values range between 0.0 and 1.0, output values are clamped to the same range.
diff --git a/midimonster.c b/midimonster.c
index 2087c28..b8594b4 100644
--- a/midimonster.c
+++ b/midimonster.c
@@ -333,6 +333,9 @@ int main(int argc, char** argv){
managed_fd* signaled_fds = NULL;
int rv = EXIT_FAILURE, error, maxfd = -1;
char* cfg_file = DEFAULT_CFG;
+ #ifdef _WIN32
+ char* error_message = NULL;
+ #endif
//parse commandline arguments
if(args_parse(argc, argv, &cfg_file)){
@@ -392,7 +395,15 @@ int main(int argc, char** argv){
tv = backend_timeout();
error = select(maxfd + 1, &read_fds, NULL, NULL, &tv);
if(error < 0){
+ #ifndef _WIN32
fprintf(stderr, "select failed: %s\n", strerror(errno));
+ #else
+ FormatMessage(FORMAT_MESSAGE_ALLOCATE_BUFFER | FORMAT_MESSAGE_FROM_SYSTEM | FORMAT_MESSAGE_IGNORE_INSERTS,
+ NULL, WSAGetLastError(), MAKELANGID(LANG_NEUTRAL, SUBLANG_DEFAULT), (LPTSTR) &error_message, 0, NULL);
+ fprintf(stderr, "select failed: %s\n", error_message);
+ LocalFree(error_message);
+ error_message = NULL;
+ #endif
break;
}