From 71eb84d5f483af8d22402de3d2ec70b08b5802d3 Mon Sep 17 00:00:00 2001 From: "Matthias P. Braendli" Date: Fri, 5 Jun 2015 09:15:56 +0200 Subject: 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. --- src/Utils.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) (limited to 'src/Utils.h') 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 #include #include +#include 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 -- cgit v1.2.3