Fix transport reset logic for hosts with non-static buffer sizes

This commit is contained in:
falkTX 2022-05-12 09:32:11 +01:00
parent a5ea17fbcf
commit c46d659340

View file

@ -448,7 +448,7 @@ class CardinalPlugin : public CardinalBasePlugin
#endif #endif
std::string fAutosavePath; std::string fAutosavePath;
uint64_t fPreviousFrame; uint64_t fNextExpectedFrame;
struct { struct {
String comment; String comment;
@ -474,7 +474,7 @@ public:
#if DISTRHO_PLUGIN_NUM_INPUTS != 0 #if DISTRHO_PLUGIN_NUM_INPUTS != 0
fAudioBufferCopy(nullptr), fAudioBufferCopy(nullptr),
#endif #endif
fPreviousFrame(0), fNextExpectedFrame(0),
fWasBypassed(false) fWasBypassed(false)
{ {
#ifndef HEADLESS #ifndef HEADLESS
@ -1082,7 +1082,7 @@ protected:
fAudioBufferCopy[i] = new float[bufferSize]; fAudioBufferCopy[i] = new float[bufferSize];
#endif #endif
fPreviousFrame = 0; fNextExpectedFrame = 0;
} }
void deactivate() override void deactivate() override
@ -1108,7 +1108,7 @@ protected:
{ {
const TimePosition& timePos(getTimePosition()); const TimePosition& timePos(getTimePosition());
const bool reset = timePos.playing && (timePos.frame == 0 || fPreviousFrame + frames != timePos.frame); const bool reset = timePos.playing && (timePos.frame == 0 || fNextExpectedFrame != timePos.frame);
context->playing = timePos.playing; context->playing = timePos.playing;
context->bbtValid = timePos.bbt.valid; context->bbtValid = timePos.bbt.valid;
@ -1133,7 +1133,7 @@ protected:
} }
context->reset = reset; context->reset = reset;
fPreviousFrame = timePos.frame; fNextExpectedFrame = timePos.playing ? timePos.frame + frames : 0;
} }
// separate buffers, use them // separate buffers, use them