diff options
author | Kevin Rushforth <[email protected]> | 2008-05-22 18:10:40 +0000 |
---|---|---|
committer | Kevin Rushforth <[email protected]> | 2008-05-22 18:10:40 +0000 |
commit | 20c2b0e727fb696596335915cc63ef56dc9cb317 (patch) | |
tree | c7c8f8203fd19277c1a3072e733a3414cce72c05 /src | |
parent | fa79b5b8b0a8d2114aebfd7028330a17cb487d2d (diff) |
1. Fixed issue 543 (see below)
2. Added release notes for 1.5.2-beta2 release
Issue number: 543
Obtained from: pepe
Submitted by: kcr
Reviewed by: kcr
Fixed issue 543: J3DClock does not adjust to clock skew
Use "-Dj3d.adjustClockSkew=true" to enable clock skew adjustment
git-svn-id: https://svn.java.net/svn/j3d-core~svn/trunk@899 ba19aa83-45c5-6ac9-afd3-db810772062c
Diffstat (limited to 'src')
-rw-r--r-- | src/classes/share/javax/media/j3d/J3dClock.java | 28 | ||||
-rw-r--r-- | src/classes/share/javax/media/j3d/MasterControl.java | 4 |
2 files changed, 28 insertions, 4 deletions
diff --git a/src/classes/share/javax/media/j3d/J3dClock.java b/src/classes/share/javax/media/j3d/J3dClock.java index fe74d83..e11c929 100644 --- a/src/classes/share/javax/media/j3d/J3dClock.java +++ b/src/classes/share/javax/media/j3d/J3dClock.java @@ -37,6 +37,10 @@ package javax.media.j3d; */ class J3dClock { + // Issue 543 - Flag to indicate whether clock skews are taken in account + // and corrected. false by default. Set by the "j3d.adjustClockSkew" property. + private static boolean skewAdjustedClock = false; + private static long deltaTime; private static final long nsecPerMsec = 1000000; @@ -45,7 +49,7 @@ class J3dClock { */ private J3dClock() { } - + /** * Returns the current time in milliseconds. This is a more * accurate version of System.currentTimeMillis and should be used in @@ -54,10 +58,30 @@ class J3dClock { * @return the current time in milliseconds. */ static long currentTimeMillis() { - return (System.nanoTime() / nsecPerMsec) + deltaTime; + if (!skewAdjustedClock) { + return (System.nanoTime() / nsecPerMsec) + deltaTime; + } else { + // Issue 543 - Adjust for possible clock skew + long time = (System.nanoTime() / nsecPerMsec) + deltaTime; + long sysTime = System.currentTimeMillis(); + if (Math.abs(time - sysTime) > 50) { + long baseTime, baseTimerValue; + synchronized (J3dClock.class) { + baseTime = System.currentTimeMillis(); + baseTimerValue = System.nanoTime(); + } + deltaTime = baseTime - (baseTimerValue / nsecPerMsec); + time = (System.nanoTime() / nsecPerMsec) + deltaTime; + } + return time; + } } static { + // Issue 543: get property for clock skew adjustment + skewAdjustedClock = MasterControl.getBooleanProperty("j3d.adjustClockSkew", + skewAdjustedClock, "clock skew adjustment"); + // Call time methods once without using their values to ensure that // the methods are "warmed up". We need to make sure that the actual // calls that we use take place as close together as possible in time. diff --git a/src/classes/share/javax/media/j3d/MasterControl.java b/src/classes/share/javax/media/j3d/MasterControl.java index 13b971b..3e44138 100644 --- a/src/classes/share/javax/media/j3d/MasterControl.java +++ b/src/classes/share/javax/media/j3d/MasterControl.java @@ -857,7 +857,7 @@ class MasterControl { }); } - private static boolean getBooleanProperty(String prop, + static boolean getBooleanProperty(String prop, boolean defaultValue, String trueMsg, String falseMsg) { @@ -871,7 +871,7 @@ class MasterControl { return value; } - private static boolean getBooleanProperty(String prop, + static boolean getBooleanProperty(String prop, boolean defaultValue, String msg) { return getBooleanProperty(prop, |