Commit 5c5ca228 authored by Andreas Schmidt's avatar Andreas Schmidt

Properly calculate timediff.

parent b7537658
Pipeline #2818 passed with stages
in 1 minute and 41 seconds
......@@ -52,20 +52,20 @@ bool PrrtSocket_pace(PrrtSocket *s, bool prepace) {
PrrtPace_track_pause(s->prrtTransmitPace);
if (s->pacingEnabled && s->nextSendTime != 0) {
debug(DEBUG_DATATRANSMITTER, "About to check for pacing.");
prrtTimeDifference_t diff = 0;
prrtTimeDiff_t diff = 0;
do {
if(PrrtSocket_closing(s)) {
result = false;
break;
}
prrtTimeDifference_t now = (prrtTimeDifference_t) PrrtClock_get_current_time_us();
diff = ((prrtTimeDifference_t) s->nextSendTime) - now;
prrtTimeDiff_t now = (prrtTimeDiff_t) PrrtClock_get_current_time_us();
diff = ((prrtTimeDiff_t) s->nextSendTime) - now;
if (!prepace) { // post-pacing removes appSendPace
diff -= PrrtPace_get_diff(s->appSendPace);
diff = MAX(0, diff);
}
if (diff > 0) {
usleep_nano((uint32_t) diff);
usleep_nano(diff);
}
} while (diff > 0);
} else {
......
......@@ -27,6 +27,7 @@ typedef uint32_t prrtTimedelta_t; // microsecond
typedef atomic_uint_fast32_t prrtAtomicTimedelta_t;
typedef int32_t prrtTimeDifference_t; // microsecond
typedef int64_t prrtTimeDiff_t; // microsecond
typedef uint32_t prrtPacketLength_t; // bytes
typedef float prrtPacketLossRate_t;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment