summaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
author 057a3dd61f99517a3afea0051a49cb27994f94d <rslovers@yandex.com>2017-05-17 13:11:53 +0000
committer GitHub <noreply@github.com>2017-05-17 13:11:53 +0000
commitb6625b410478d866aab6b84e40e0ddf090205029 (patch)
tree854710db9e9f378b135224391f3ebfe3a0aac403
parentfc0a2a32e00f74575934e0fb728312cdf0489dee (diff)
Fix video_manager::throttle_until_ticks (#2309)
Do not update m_average_oversleep if we overslept too much. This is still a partial fix, more investigation is needed when the system time jumps backward.
-rw-r--r--src/emu/video.cpp7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/emu/video.cpp b/src/emu/video.cpp
index 981dd69672d..15fbe54eb83 100644
--- a/src/emu/video.cpp
+++ b/src/emu/video.cpp
@@ -914,8 +914,13 @@ osd_ticks_t video_manager::throttle_until_ticks(osd_ticks_t target_ticks)
if (slept)
{
// if we overslept, keep an average of the amount
+ // however, if we overslept too much, which is very likely resulted by a system time
+ // change, instead of inaccuracy of sleep, we should not update this average amount, as
+ // it's both a wrong reflection of the average and will potentially cause delta to be
+ // calculated as a very small value, even less than minimum_sleep, which will make this
+ // loop to be a busy one wasting cpu resource
osd_ticks_t actual_ticks = new_ticks - current_ticks;
- if (actual_ticks > delta)
+ if (actual_ticks > delta && actual_ticks < delta * 2)
{
// take 90% of the previous average plus 10% of the new value
osd_ticks_t oversleep_milliticks = 1000 * (actual_ticks - delta) / delta;