From 0bae94ad2c8705abb3ea54fc375153d746633007 Mon Sep 17 00:00:00 2001 From: tildearrow Date: Tue, 18 Nov 2025 02:51:20 -0500 Subject: [PATCH] fix certain issues with TimeMicros --- src/engine/playback.cpp | 5 ++--- src/timeutils.h | 20 ++++++++++++++++---- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/src/engine/playback.cpp b/src/engine/playback.cpp index 72852444d..d179240c3 100644 --- a/src/engine/playback.cpp +++ b/src/engine/playback.cpp @@ -2136,9 +2136,8 @@ bool DivEngine::nextTick(bool noAccum, bool inhibitLowLat) { // advance tempo accumulator (for virtual tempo) unless we are step playing and waiting for the next step (stepPlay==2) // then advance tick counter and then call nextRow() if (stepPlay!=1) { - // fast-forward the accumulator if we are "skipping" (seeking to a position) - // otherwise increase accumulator by virtual tempo numerator - tempoAccum+=(skipping && virtualTempoN=virtualTempoD) { // wrap the accumulator back diff --git a/src/timeutils.h b/src/timeutils.h index 48b1d3cbe..ef79bd2eb 100644 --- a/src/timeutils.h +++ b/src/timeutils.h @@ -55,7 +55,7 @@ struct TimeMicros { } // operators - inline TimeMicros& operator+(TimeMicros& other) { + inline TimeMicros& operator+=(TimeMicros& other) { seconds+=other.seconds; micros+=other.micros; while (micros>=1000000) { @@ -64,11 +64,11 @@ struct TimeMicros { } return *this; } - inline TimeMicros& operator+(int other) { + inline TimeMicros& operator+=(int other) { seconds+=other; return *this; } - inline TimeMicros& operator-(TimeMicros& other) { + inline TimeMicros& operator-=(TimeMicros& other) { seconds-=other.seconds; micros-=other.micros; while (micros<0) { @@ -77,7 +77,7 @@ struct TimeMicros { } return *this; } - inline TimeMicros& operator-(int other) { + inline TimeMicros& operator-=(int other) { seconds-=other; return *this; } @@ -124,4 +124,16 @@ struct TimeMicros { seconds(0), micros(0) {} }; +inline TimeMicros operator+(TimeMicros& t1, TimeMicros t2) { + TimeMicros result=t1; + result+=t2; + return result; +} + +inline TimeMicros operator-(TimeMicros& t1, TimeMicros t2) { + TimeMicros result=t1; + result-=t2; + return result; +} + #endif