From e693d9beef4b15301111c7805d14a0c70476e46d Mon Sep 17 00:00:00 2001 From: Andrew Belt Date: Fri, 10 May 2019 13:34:27 -0400 Subject: [PATCH] Fix submodule broken by previous commit. --- dep/glfw | 2 +- dep/nanosvg | 2 +- dep/nanovg | 2 +- dep/rtaudio | 2 +- src/engine/Engine.cpp | 15 ++++++++------- 5 files changed, 12 insertions(+), 11 deletions(-) diff --git a/dep/glfw b/dep/glfw index 7ba23eb0..d9ab59ef 160000 --- a/dep/glfw +++ b/dep/glfw @@ -1 +1 @@ -Subproject commit 7ba23eb03854dfe6ce36cc6d61cb913f76cad774 +Subproject commit d9ab59efc781c392128a449361a381fcc93cf6f3 diff --git a/dep/nanosvg b/dep/nanosvg index c1f6e209..25241c5a 160000 --- a/dep/nanosvg +++ b/dep/nanosvg @@ -1 +1 @@ -Subproject commit c1f6e209c16b18b46aa9f45d7e619acf42c29726 +Subproject commit 25241c5a8f8451d41ab1b02ab2d865b01600d949 diff --git a/dep/nanovg b/dep/nanovg index f4069e6a..1f9c8864 160000 --- a/dep/nanovg +++ b/dep/nanovg @@ -1 +1 @@ -Subproject commit f4069e6a1ad5da430fb0a9c57476d5ddc2ff89b2 +Subproject commit 1f9c8864fc556a1be4d4bf1d6bfe20cde25734b4 diff --git a/dep/rtaudio b/dep/rtaudio index b9468aa6..d27f257b 160000 --- a/dep/rtaudio +++ b/dep/rtaudio @@ -1 +1 @@ -Subproject commit b9468aa6f82fdea1f3dc364f477e859b39f0bb2a +Subproject commit d27f257b4bc827e4152cdc4d69a2e22084204afd diff --git a/src/engine/Engine.cpp b/src/engine/Engine.cpp index 4b1b6cf1..7fa53813 100644 --- a/src/engine/Engine.cpp +++ b/src/engine/Engine.cpp @@ -233,7 +233,7 @@ static void Engine_stepModules(Engine *that, int threadId) { // Step each module // for (int i = threadId; i < modulesLen; i += threadCount) { while (true) { - // Chose module + // Choose next module int i = internal->workerModuleIndex++; if (i >= modulesLen) break; @@ -277,7 +277,7 @@ static void Engine_step(Engine *that) { if (smoothModule) { Param *param = &smoothModule->params[smoothParamId]; float value = param->value; - // decay rate is 1 graphics frame + // Decay rate is 1 graphics frame const float smoothLambda = 60.f; float newValue = value + (smoothValue - value) * smoothLambda * internal->sampleTime; if (value == newValue) { @@ -377,7 +377,7 @@ static void Engine_run(Engine *that) { // Every time the that waits and locks a mutex, it steps this many frames const int mutexSteps = 128; // Time in seconds that the that is rushing ahead of the estimated clock time - double ahead = 0.0; + double aheadTime = 0.0; auto lastTime = std::chrono::high_resolution_clock::now(); while (internal->running) { @@ -390,6 +390,7 @@ static void Engine_run(Engine *that) { for (Module *module : internal->modules) { module->onSampleRateChange(); } + aheadTime = 0.0; } // Launch workers @@ -413,17 +414,17 @@ static void Engine_run(Engine *that) { } double stepTime = mutexSteps * internal->sampleTime; - ahead += stepTime; + aheadTime += stepTime; auto currTime = std::chrono::high_resolution_clock::now(); const double aheadFactor = 2.0; - ahead -= aheadFactor * std::chrono::duration(currTime - lastTime).count(); + aheadTime -= aheadFactor * std::chrono::duration(currTime - lastTime).count(); lastTime = currTime; - ahead = std::fmax(ahead, 0.0); + aheadTime = std::fmax(aheadTime, 0.0); // Avoid pegging the CPU at 100% when there are no "blocking" modules like AudioInterface, but still step audio at a reasonable rate // The number of steps to wait before possibly sleeping const double aheadMax = 1.0; // seconds - if (ahead > aheadMax) { + if (aheadTime > aheadMax) { std::this_thread::sleep_for(std::chrono::duration(stepTime)); } }