Browse Source

Add Engine::getFrame().

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
1252437344
2 changed files with 9 additions and 0 deletions
  1. +1
    -0
      include/engine/Engine.hpp
  2. +8
    -0
      src/engine/Engine.cpp

+ 1
- 0
include/engine/Engine.hpp View File

@@ -29,6 +29,7 @@ struct Engine {
Call this in your Module::step() method to hint that the operation will take more than ~0.1 ms.
*/
void yieldWorkers();
uint64_t getFrame();

// Modules
/** Adds a module to the rack engine.


+ 8
- 0
src/engine/Engine.cpp View File

@@ -178,6 +178,7 @@ struct Engine::Internal {
bool running = false;
float sampleRate;
float sampleTime;
uint64_t frame = 0;

int nextModuleId = 0;
int nextCableId = 0;
@@ -333,6 +334,8 @@ static void Engine_step(Engine *that) {
internal->engineBarrier.wait();
Engine_stepModules(that, 0);
internal->workerBarrier.wait();

internal->frame++;
}

static void Engine_updateExpander(Engine *that, Module::Expander *expander) {
@@ -388,6 +391,7 @@ static void Engine_run(Engine *that) {
// system::setThreadRealTime();
disableDenormals();

internal->frame = 0;
// 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
@@ -486,6 +490,10 @@ void Engine::yieldWorkers() {
internal->workerBarrier.yield = true;
}

uint64_t Engine::getFrame() {
return internal->frame;
}

void Engine::addModule(Module *module) {
assert(module);
VIPLock vipLock(internal->vipMutex);


Loading…
Cancel
Save