Tolerate max 2 frames of deviation for frame position skips

Signed-off-by: falkTX <falktx@falktx.com>
This commit is contained in:
falkTX 2022-06-25 23:37:49 +01:00
parent 68855c10d2
commit ec2222be85
No known key found for this signature in database
GPG key ID: CDBAA37ABC74FBA0
2 changed files with 9 additions and 2 deletions

View file

@ -81,6 +81,13 @@ namespace window {
START_NAMESPACE_DISTRHO
template<typename T>
static inline
bool d_isDiffHigherThanLimit(const T& v1, const T& v2, const T& limit)
{
return v1 != v2 ? (v1 > v2 ? v1 - v2 : v2 - v1) > limit : false;
}
// -----------------------------------------------------------------------------------------------------------
struct Initializer
@ -1117,7 +1124,7 @@ protected:
{
const TimePosition& timePos(getTimePosition());
const bool reset = timePos.playing && (timePos.frame == 0 || fNextExpectedFrame != timePos.frame);
const bool reset = timePos.playing && (timePos.frame == 0 || d_isDiffHigherThanLimit(fNextExpectedFrame, timePos.frame, (uint64_t)2));
context->playing = timePos.playing;
context->bbtValid = timePos.bbt.valid;