From d349c1f91a94e934036d672e0ef6694d26fbc85f Mon Sep 17 00:00:00 2001 From: Dave Hoover Date: Tue, 11 Mar 2008 18:16:16 +0000 Subject: [PATCH] Pull out our drift range to constants, and tighten it up a little bit. git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@441 ed5b42cb-e716-0410-a449-f6a68f950b19 --- src/java/com/threerings/media/timer/CalibratingTimer.java | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/java/com/threerings/media/timer/CalibratingTimer.java b/src/java/com/threerings/media/timer/CalibratingTimer.java index 95af3044..39b7fe87 100644 --- a/src/java/com/threerings/media/timer/CalibratingTimer.java +++ b/src/java/com/threerings/media/timer/CalibratingTimer.java @@ -114,7 +114,7 @@ public abstract class CalibratingTimer + ", drift=" + drift + ", timerstamp=" + _driftTimerStamp + ", millistamp=" + _driftMilliStamp + ", current=" + current + "]"); } - if (drift > 1.25 || drift < 0.75) { + if (drift > MAX_ALLOWED_DRIFT_RATIO || drift < MIN_ALLOWED_DRIFT_RATIO) { Log.warning("Calibrating [drift=" + drift + "]"); _driftRatio = drift; if (Math.abs(drift - 1.0) > Math.abs(_maxDriftRatio - 1.0)) { @@ -131,6 +131,12 @@ public abstract class CalibratingTimer /** Return the current value for this timer. */ public abstract long current (); + + /** The largest drift ratio we'll allow without correcting. */ + protected static final double MAX_ALLOWED_DRIFT_RATIO = 1.1; + + /** The smallest drift ratio we'll allow without correcting. */ + protected static final double MIN_ALLOWED_DRIFT_RATIO = 0.9; /** current() value when the timer was started. */ protected long _startStamp;