Fix this user of samskivert's log object.
git-svn-id: svn+ssh://src.earth.threerings.net/nenya/trunk@507 ed5b42cb-e716-0410-a449-f6a68f950b19
This commit is contained in:
@@ -21,9 +21,9 @@
|
||||
|
||||
package com.threerings.media.timer;
|
||||
|
||||
import com.samskivert.Log;
|
||||
import com.samskivert.swing.RuntimeAdjust;
|
||||
import com.samskivert.util.Interval;
|
||||
import com.samskivert.util.Logger;
|
||||
import com.threerings.media.MediaPrefs;
|
||||
|
||||
/**
|
||||
@@ -36,7 +36,7 @@ public abstract class CalibratingTimer
|
||||
{
|
||||
/**
|
||||
* Initializes this timer. Must be called before the timer is used.
|
||||
*
|
||||
*
|
||||
* @param milliDivider - value by which current() must be divided to get milliseconds
|
||||
* @param microDivider - value by which current() must be divided to get microseconds
|
||||
*/
|
||||
@@ -45,8 +45,8 @@ public abstract class CalibratingTimer
|
||||
_milliDivider = milliDivider;
|
||||
_microDivider = microDivider;
|
||||
reset();
|
||||
Log.info("Using " + getClass() + " timer [mfreq=" + _milliDivider + ", ufreq="
|
||||
+ _microDivider + ", start=" + _startStamp + "].");
|
||||
log.info("Using " + getClass() + " timer", "mfreq", _milliDivider,
|
||||
"ufreq", _microDivider, "start", _startStamp);
|
||||
}
|
||||
|
||||
// documentation inherited from interface
|
||||
@@ -78,7 +78,10 @@ public abstract class CalibratingTimer
|
||||
};
|
||||
_calibrateInterval.schedule(CALIBRATE_INTERVAL, CALIBRATE_INTERVAL, false);
|
||||
}
|
||||
|
||||
|
||||
/** Return the current value for this timer. */
|
||||
public abstract long current ();
|
||||
|
||||
/**
|
||||
* Returns the greatest drift ratio we've had to compensate for.
|
||||
*/
|
||||
@@ -86,7 +89,7 @@ public abstract class CalibratingTimer
|
||||
{
|
||||
return _maxDriftRatio;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Clears out our remembered max drift.
|
||||
*/
|
||||
@@ -116,46 +119,37 @@ public abstract class CalibratingTimer
|
||||
float elapsedMillis = currentMillis - _driftMilliStamp;
|
||||
float drift = elapsedMillis / (elapsedTimer / _milliDivider);
|
||||
if (_debugCalibrate.getValue()) {
|
||||
Log.warning("Calibrating [timer=" + elapsedTimer + ", millis=" + elapsedMillis
|
||||
+ ", drift=" + drift + ", timerstamp=" + _driftTimerStamp + ", millistamp="
|
||||
+ _driftMilliStamp + ", current=" + currentTimer + "]");
|
||||
log.warning("Calibrating", "timer", elapsedTimer, "millis", elapsedMillis,
|
||||
"drift", drift, "timerstamp", _driftTimerStamp,
|
||||
"millistamp", _driftMilliStamp, "current", currentTimer);
|
||||
}
|
||||
|
||||
if (elapsedTimer < 0) {
|
||||
Log.warning("The timer has decided to live in the past, resetting drift[previousTimer="
|
||||
+ _driftTimerStamp + ", currentTimer=" + currentTimer + ", previousMillis="
|
||||
+ _driftMilliStamp + ", currentMillis=" + currentMillis + "]");
|
||||
log.warning("The timer has decided to live in the past, resetting drift" ,
|
||||
"previousTimer", _driftTimerStamp, "currentTimer", currentTimer,
|
||||
"previousMillis", _driftMilliStamp, "currentMillis", currentMillis);
|
||||
_driftRatio = 1.0F;
|
||||
|
||||
} else if (drift > MAX_ALLOWED_DRIFT_RATIO || drift < MIN_ALLOWED_DRIFT_RATIO) {
|
||||
Log.warning("Calibrating [drift=" + drift + "]");
|
||||
log.warning("Calibrating", "drift", drift);
|
||||
// Keep the drift somewhat sane between .01 and 10
|
||||
_driftRatio = (float)Math.min(Math.max(.01, drift), 10);
|
||||
if (Math.abs(drift - 1.0) > Math.abs(_maxDriftRatio - 1.0)) {
|
||||
_maxDriftRatio = drift;
|
||||
}
|
||||
|
||||
} else if (_driftRatio != 1.0) {
|
||||
log.warning("Calibrating", "drift", drift);
|
||||
// If we're within bounds now but we weren't before, reset _driftFactor and log it
|
||||
_driftRatio = 1.0F;
|
||||
Log.warning("Calibrating [drift=" + drift + "]");
|
||||
}
|
||||
_driftMilliStamp = currentMillis;
|
||||
_driftTimerStamp = currentTimer;
|
||||
}
|
||||
|
||||
/** Return the current value for this timer. */
|
||||
public abstract long current ();
|
||||
|
||||
/** The largest drift ratio we'll allow without correcting. */
|
||||
protected static final float MAX_ALLOWED_DRIFT_RATIO = 1.1F;
|
||||
|
||||
/** The smallest drift ratio we'll allow without correcting. */
|
||||
protected static final float MIN_ALLOWED_DRIFT_RATIO = 0.9F;
|
||||
|
||||
/** Milliseconds between calibrate calls. */
|
||||
protected static final int CALIBRATE_INTERVAL = 5000;
|
||||
|
||||
/** current() value when the timer was started. */
|
||||
protected long _startStamp;
|
||||
|
||||
|
||||
/** current() value when elapsed was called last. */
|
||||
protected long _priorCurrent;
|
||||
|
||||
@@ -173,13 +167,25 @@ public abstract class CalibratingTimer
|
||||
|
||||
/** Ratio of currentTimeMillis to timer millis. */
|
||||
protected float _driftRatio = 1.0F;
|
||||
|
||||
|
||||
/** The largest drift we've had to adjust for. */
|
||||
protected float _maxDriftRatio = 1.0F;
|
||||
|
||||
|
||||
/** Interval that fires every five seconds to run the calibration. */
|
||||
protected Interval _calibrateInterval;
|
||||
|
||||
|
||||
/** Used to log things. */
|
||||
protected final Logger log = Logger.getLogger(CalibratingTimer.class);
|
||||
|
||||
/** The largest drift ratio we'll allow without correcting. */
|
||||
protected static final float MAX_ALLOWED_DRIFT_RATIO = 1.1F;
|
||||
|
||||
/** The smallest drift ratio we'll allow without correcting. */
|
||||
protected static final float MIN_ALLOWED_DRIFT_RATIO = 0.9F;
|
||||
|
||||
/** Milliseconds between calibrate calls. */
|
||||
protected static final int CALIBRATE_INTERVAL = 5000;
|
||||
|
||||
/** A debug hook that toggles dumping of calibration values. */
|
||||
protected static RuntimeAdjust.BooleanAdjust _debugCalibrate = new RuntimeAdjust.BooleanAdjust(
|
||||
"Toggles calibrations statistics", "narya.media.timer",
|
||||
|
||||
Reference in New Issue
Block a user