From 6928f9aa9660f772fa2ba0328001cb2f08d0aaf8 Mon Sep 17 00:00:00 2001 From: Michael Bayne Date: Tue, 29 Jul 2003 00:41:40 +0000 Subject: [PATCH] We need to handle this in the frame manager because all we can do in SystemMediaTimer is make time stop while we're in the past, whereas in the FrameManager we can just note that strangeness is afoot and keep on tickin'. git-svn-id: svn+ssh://src.earth.threerings.net/narya/trunk@2736 542714f4-19e9-0310-aa3c-eee0fc999fb1 --- .../com/threerings/media/FrameManager.java | 12 +++++++++- .../media/timer/SystemMediaTimer.java | 23 ++----------------- 2 files changed, 13 insertions(+), 22 deletions(-) diff --git a/src/java/com/threerings/media/FrameManager.java b/src/java/com/threerings/media/FrameManager.java index 214b7b6e4..86d0bdeb6 100644 --- a/src/java/com/threerings/media/FrameManager.java +++ b/src/java/com/threerings/media/FrameManager.java @@ -1,5 +1,5 @@ // -// $Id: FrameManager.java,v 1.43 2003/05/19 03:01:13 mdb Exp $ +// $Id: FrameManager.java,v 1.44 2003/07/29 00:41:40 mdb Exp $ package com.threerings.media; @@ -696,6 +696,16 @@ public abstract class FrameManager if (start > 0L) { getPerfMetrics()[0].record((int)(woke-start)); } + + // work around sketchy bug on WinXP that causes the clock + // to leap into the past from time to time + if (woke < _lastAttempt) { + Log.warning("Zoiks! We've leapt into the past, coping " + + "as best we can [dt=" + + (woke - _lastAttempt) + "]."); + _lastAttempt = woke; + } + if (woke - _lastAttempt >= _millisPerFrame) { _lastAttempt = woke; if (testAndSet()) { diff --git a/src/java/com/threerings/media/timer/SystemMediaTimer.java b/src/java/com/threerings/media/timer/SystemMediaTimer.java index 5f05cd068..2055174b5 100644 --- a/src/java/com/threerings/media/timer/SystemMediaTimer.java +++ b/src/java/com/threerings/media/timer/SystemMediaTimer.java @@ -1,5 +1,5 @@ // -// $Id: SystemMediaTimer.java,v 1.2 2003/07/29 00:27:32 mdb Exp $ +// $Id: SystemMediaTimer.java,v 1.3 2003/07/29 00:41:40 mdb Exp $ package com.threerings.media.timer; @@ -25,23 +25,7 @@ public class SystemMediaTimer implements MediaTimer // documentation inherited from interface public long getElapsedMillis () { - long stamp = System.currentTimeMillis() - _resetStamp; - - // on WinXP the time sometimes seems to leap into the - // past; here we do our best to work around this insanity - if (stamp < _lastStamp) { - // only warn once per time anomaly - if (stamp > _lastWarning) { - Log.warning("Someone call Einstein! The clock is " + - "running backwards [dt=" + - (stamp - _lastStamp) + "]."); - _lastWarning = _lastStamp; - } - stamp = _lastStamp; - } - _lastStamp = stamp; - - return stamp; + return System.currentTimeMillis() - _resetStamp; } // documentation inherited from interface @@ -52,7 +36,4 @@ public class SystemMediaTimer implements MediaTimer /** The time at which this timer was last reset. */ protected long _resetStamp = System.currentTimeMillis(); - - /** Used to ensure that the timer is sane. */ - protected long _lastStamp, _lastWarning; }