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
This commit is contained in:
@@ -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()) {
|
||||
|
||||
@@ -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;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user