History

merge new work into andrew/inertia

Andrew Meadows committed 12 years ago

Commit a7c4b022 parents 39252a8 b05a31554 files · +938 −883Browse files

Showing the changes to libraries/script-engine/src/ScriptEngine.cpp (1 of 54 files). Show all

Unified · Split

libraries/script-engine/src/ScriptEngine.cpp+3−3
@@ -294,8 +294,8 @@ void ScriptEngine::run() { · 293 unmodified lines
294 emit errorMessage("Uncaught exception at line" + QString::number(line) + ":" + result.toString());294 emit errorMessage("Uncaught exception at line" + QString::number(line) + ":" + result.toString());
295 }295 }
296 296
297 timeval startTime;297 QElapsedTimer startTime;
298 gettimeofday(&startTime, NULL);298 startTime.start();
299 299
300 int thisFrame = 0;300 int thisFrame = 0;
301 301
@@ -304,7 +304,7 @@ void ScriptEngine::run() { · 2 unmodified lines
304 qint64 lastUpdate = usecTimestampNow();304 qint64 lastUpdate = usecTimestampNow();
305 305
306 while (!_isFinished) {306 while (!_isFinished) {
307 int usecToSleep = usecTimestamp(&startTime) + (thisFrame++ * SCRIPT_DATA_CALLBACK_USECS) - usecTimestampNow();307 int usecToSleep = (thisFrame++ * SCRIPT_DATA_CALLBACK_USECS) - startTime.nsecsElapsed() / 1000; // nsec to usec
308 if (usecToSleep > 0) {308 if (usecToSleep > 0) {
309 usleep(usecToSleep);309 usleep(usecToSleep);
310 }310 }