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. Call this in your Module::step() method to hint that the operation will take more than ~0.1 ms.
*/ */
void yieldWorkers(); void yieldWorkers();
uint64_t getFrame();


// Modules // Modules
/** Adds a module to the rack engine. /** 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; bool running = false;
float sampleRate; float sampleRate;
float sampleTime; float sampleTime;
uint64_t frame = 0;


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

internal->frame++;
} }


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


internal->frame = 0;
// Every time the that waits and locks a mutex, it steps this many frames // Every time the that waits and locks a mutex, it steps this many frames
const int mutexSteps = 128; const int mutexSteps = 128;
// Time in seconds that the that is rushing ahead of the estimated clock time // 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; internal->workerBarrier.yield = true;
} }


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

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


Loading…
Cancel
Save