From 62740fe5461695ef485ce1c54e725b6cab8a0d7e Mon Sep 17 00:00:00 2001 From: Charlie Groves Date: Sun, 14 Sep 2008 23:27:29 +0000 Subject: [PATCH] Rather than trying to restrict the drift adjustment into a sane range, just stop applying it if it's huge or tiny. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@656 ed5b42cb-e716-0410-a449-f6a68f950b19 --- src/java/com/threerings/media/FrameManager.java | 4 ++-- .../com/threerings/media/timer/CalibratingTimer.java | 11 ++++++++--- 2 files changed, 10 insertions(+), 5 deletions(-) diff --git a/src/java/com/threerings/media/FrameManager.java b/src/java/com/threerings/media/FrameManager.java index 0195d031..95f9b511 100644 --- a/src/java/com/threerings/media/FrameManager.java +++ b/src/java/com/threerings/media/FrameManager.java @@ -221,12 +221,12 @@ public abstract class FrameManager * Returns the highest drift ratio our timer has seen. 1.0 means no drift (and is what we return * if we're not using a CalibratingTimer) */ - public double getMaxTimerDriftRatio () + public float getMaxTimerDriftRatio () { if (_timer instanceof CalibratingTimer) { return ((CalibratingTimer)_timer).getMaxDriftRatio(); } else { - return 1.0; + return 1.0F; } } diff --git a/src/java/com/threerings/media/timer/CalibratingTimer.java b/src/java/com/threerings/media/timer/CalibratingTimer.java index 2afc71dc..2b1cb03e 100644 --- a/src/java/com/threerings/media/timer/CalibratingTimer.java +++ b/src/java/com/threerings/media/timer/CalibratingTimer.java @@ -85,7 +85,7 @@ public abstract class CalibratingTimer /** * Returns the greatest drift ratio we've had to compensate for. */ - public double getMaxDriftRatio () + public float getMaxDriftRatio () { return _maxDriftRatio; } @@ -132,8 +132,13 @@ public abstract class CalibratingTimer } else if (drift > MAX_ALLOWED_DRIFT_RATIO || drift < MIN_ALLOWED_DRIFT_RATIO) { log.warning("Calibrating", "drift", drift); - // Keep the drift somewhat sane between .01 and 10 - _driftRatio = (float)Math.min(Math.max(.01, drift), 10); + // Ignore the drift if it's hugely out of range. That indicates general clock insanity, + // and we just want to stay out of the way. + if (drift < 100 * MAX_ALLOWED_DRIFT_RATIO && drift > MIN_ALLOWED_DRIFT_RATIO / 100) { + _driftRatio = drift; + } else { + _driftRatio = 1.0F; + } if (Math.abs(drift - 1.0) > Math.abs(_maxDriftRatio - 1.0)) { _maxDriftRatio = drift; }