aboutsummaryrefslogtreecommitdiffstats
path: root/src/Utils.h
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2015-06-05 09:15:56 +0200
committerMatthias P. Braendli <matthias.braendli@mpb.li>2015-06-05 09:22:22 +0200
commit71eb84d5f483af8d22402de3d2ec70b08b5802d3 (patch)
tree589fd978bdc357a0c67179d83c5c04bb0d732082 /src/Utils.h
parentc9ea7fb88809d935f3eaeee108415ff5abd17ead (diff)
downloaddabmod-71eb84d5f483af8d22402de3d2ec70b08b5802d3.tar.gz
dabmod-71eb84d5f483af8d22402de3d2ec70b08b5802d3.tar.bz2
dabmod-71eb84d5f483af8d22402de3d2ec70b08b5802d3.zip
Fix intermittent underruns after a restart
When using UHD without synchronous=1: After a modulator restart, the input ZMQ buffer is nearly empty, and the modulator actually gets blocked by the ThreadsafeQueue. This is visible by looking at the time deltas printed in the debugging code. This commit adds a minimal form of prebuffering (10 ETI frames) to the ZeroMQ input, and removes the useless minimum required size for the ThreadsafeQueue. In synchronous=1, the issue is not visible because the TIST defines the time to transmit, which will cause the ZMQ buffer to fill.
Diffstat (limited to 'src/Utils.h')
-rw-r--r--src/Utils.h18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/Utils.h b/src/Utils.h
index 7c3129c..f023646 100644
--- a/src/Utils.h
+++ b/src/Utils.h
@@ -35,10 +35,28 @@
#include <stdlib.h>
#include <unistd.h>
#include <stdio.h>
+#include <time.h>
void printUsage(char* progName);
void printVersion(void);
+inline long timespecdiff_us(struct timespec& oldTime, struct timespec& time)
+{
+ long tv_sec;
+ long tv_nsec;
+ if (time.tv_nsec < oldTime.tv_nsec) {
+ tv_sec = time.tv_sec - 1 - oldTime.tv_sec;
+ tv_nsec = 1000000000L + time.tv_nsec - oldTime.tv_nsec;
+ }
+ else {
+ tv_sec = time.tv_sec - oldTime.tv_sec;
+ tv_nsec = time.tv_nsec - oldTime.tv_nsec;
+ }
+
+ return tv_sec * 1000 + tv_nsec / 1000;
+}
+
+
#endif