MCPcopy Create free account
hub / github.com/VCVRack/Rack / Engine_fallbackRun

Function Engine_fallbackRun

src/engine/Engine.cpp:1384–1409  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1382
1383
1384static void Engine_fallbackRun(Engine* that) {
1385 system::setThreadName("Engine fallback");
1386 contextSet(that->internal->context);
1387
1388 while (that->internal->fallbackRunning) {
1389 if (!that->getMasterModule()) {
1390 // Step blocks and wait
1391 double start = system::getTime();
1392 int frames = std::floor(that->getSampleRate() / 60);
1393 that->stepBlock(frames);
1394 double end = system::getTime();
1395
1396 double duration = frames * that->getSampleTime() - (end - start);
1397 if (duration > 0.0) {
1398 std::this_thread::sleep_for(std::chrono::duration<double>(duration));
1399 }
1400 }
1401 else {
1402 // Wait for master module to be unset, or for the request to stop running
1403 std::unique_lock<std::mutex> lock(that->internal->fallbackMutex);
1404 that->internal->fallbackCv.wait(lock, [&]() {
1405 return !that->internal->fallbackRunning || !that->getMasterModule();
1406 });
1407 }
1408 }
1409}
1410
1411
1412void Engine::startFallbackThread() {

Callers

nothing calls this directly

Calls 9

setThreadNameFunction · 0.85
contextSetFunction · 0.85
getTimeFunction · 0.85
floorFunction · 0.85
getMasterModuleMethod · 0.80
stepBlockMethod · 0.80
getSampleTimeMethod · 0.80
getSampleRateMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected