Have interval as constant, and set lower value

This commit is contained in:
Jean Pierre Cimalando 2021-03-18 11:24:55 +01:00
parent 7b49e43275
commit cf2832d462

View file

@ -14,6 +14,7 @@
#include "pluginterfaces/vst/ivstevents.h" #include "pluginterfaces/vst/ivstevents.h"
#include "pluginterfaces/vst/ivstparameterchanges.h" #include "pluginterfaces/vst/ivstparameterchanges.h"
#include <ghc/fs_std.hpp> #include <ghc/fs_std.hpp>
#include <chrono>
#include <cstring> #include <cstring>
template<class T> template<class T>
@ -41,6 +42,8 @@ static const char* kMsgIdNotifyPlayState = "NotifyPlayState";
static const char* kMsgIdReceiveMessage = "ReceiveMessage"; static const char* kMsgIdReceiveMessage = "ReceiveMessage";
static const char* kMsgIdNoteEvents = "NoteEvents"; static const char* kMsgIdNoteEvents = "NoteEvents";
static constexpr std::chrono::milliseconds kBackgroundIdleInterval { 500 };
SfizzVstProcessor::SfizzVstProcessor() SfizzVstProcessor::SfizzVstProcessor()
: _fifoToWorker(64 * 1024), _fifoMessageFromUi(64 * 1024), : _fifoToWorker(64 * 1024), _fifoMessageFromUi(64 * 1024),
_oscTemp(new uint8_t[kOscTempSize]) _oscTemp(new uint8_t[kOscTempSize])
@ -637,7 +640,7 @@ void SfizzVstProcessor::doBackgroundWork()
Clock::time_point lastIdleWorkTime; Clock::time_point lastIdleWorkTime;
for (;;) { for (;;) {
bool isNotified = _semaToWorker.timed_wait(1000); bool isNotified = _semaToWorker.timed_wait(kBackgroundIdleInterval.count());
if (!_workRunning) if (!_workRunning)
break; break;
@ -690,7 +693,7 @@ void SfizzVstProcessor::doBackgroundWork()
} }
Clock::time_point currentTime = Clock::now(); Clock::time_point currentTime = Clock::now();
if (!haveDoneIdleWork || currentTime - lastIdleWorkTime > std::chrono::seconds(1)) { if (!haveDoneIdleWork || currentTime - lastIdleWorkTime > kBackgroundIdleInterval) {
doBackgroundIdle(); doBackgroundIdle();
haveDoneIdleWork = true; haveDoneIdleWork = true;
lastIdleWorkTime = currentTime; lastIdleWorkTime = currentTime;