1
0
mirror of https://github.com/TomHarte/CLK.git synced 2025-02-21 05:29:13 +00:00

Improve sanity check.

This commit is contained in:
Thomas Harte 2021-02-16 19:47:25 -05:00
parent 28bd620e7f
commit 35be402354

View File

@ -723,17 +723,22 @@ struct ActivityObserver: public Activity::Observer {
// _syncTime = 0 is used here as a sentinel to mark that a sync time is known; // _syncTime = 0 is used here as a sentinel to mark that a sync time is known;
// this with the >= test ensures that no syncs are missed even if some sort of // this with the >= test ensures that no syncs are missed even if some sort of
// performance problem is afoot (e.g. I'm debugging). // performance problem is afoot (e.g. I'm debugging).
if(self->_syncTime && timeNow >= self->_syncTime && self->_syncTime >= lastTime) { if(self->_syncTime && timeNow >= self->_syncTime) {
splitAndSync = self->_isSyncLocking = self->_scanSynchroniser.can_synchronise(self->_machine->scan_producer()->get_scan_status(), self->_refreshPeriod); splitAndSync = self->_isSyncLocking = self->_scanSynchroniser.can_synchronise(self->_machine->scan_producer()->get_scan_status(), self->_refreshPeriod);
// If the time window is being split, run up to the split, then check out machine speed, possibly // If the time window is being split, run up to the split, then check out machine speed, possibly
// adjusting multiplier, then run after the split. // adjusting multiplier, then run after the split. Include a sanity check against an out-of-bounds
// _syncTime; that can happen when debugging (possibly inter alia?).
if(splitAndSync) { if(splitAndSync) {
self->_machine->timed_machine()->run_for((double)(self->_syncTime - lastTime) / 1e9); if(self->_syncTime >= lastTime) {
self->_machine->timed_machine()->set_speed_multiplier( self->_machine->timed_machine()->run_for((double)(self->_syncTime - lastTime) / 1e9);
self->_scanSynchroniser.next_speed_multiplier(self->_machine->scan_producer()->get_scan_status()) self->_machine->timed_machine()->set_speed_multiplier(
); self->_scanSynchroniser.next_speed_multiplier(self->_machine->scan_producer()->get_scan_status())
self->_machine->timed_machine()->run_for((double)(timeNow - self->_syncTime) / 1e9); );
self->_machine->timed_machine()->run_for((double)(timeNow - self->_syncTime) / 1e9);
} else {
self->_machine->timed_machine()->run_for((double)(timeNow - lastTime) / 1e9);
}
} }
self->_syncTime = 0; self->_syncTime = 0;