[Development] Using index-driven positioning when seeking forward over more than 10 seconds.

git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2621 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/java/src/com/tightvnc/rfbplayer/FbsInputStream.java b/java/src/com/tightvnc/rfbplayer/FbsInputStream.java
index db02a1d..2077bc5 100644
--- a/java/src/com/tightvnc/rfbplayer/FbsInputStream.java
+++ b/java/src/com/tightvnc/rfbplayer/FbsInputStream.java
@@ -33,7 +33,7 @@
   protected long startTime;
   protected long timeOffset;
   protected long seekOffset;
-  protected boolean seekBackwards;
+  protected boolean farSeeking;
   protected boolean paused;
   protected boolean isQuitting = false;
   protected double playbackSpeed;
@@ -101,7 +101,7 @@
     startTime = System.currentTimeMillis() - timeOffset;
     this.timeOffset = timeOffset;
     seekOffset = -1;
-    seekBackwards = false;
+    farSeeking = false;
     paused = false;
     playbackSpeed = 1.0;
 
@@ -147,7 +147,7 @@
     startTime = -1;
     timeOffset = 0;
     seekOffset = -1;
-    seekBackwards = false;
+    farSeeking = false;
     paused = false;
     playbackSpeed = 1.0;
 
@@ -169,8 +169,9 @@
 
   public synchronized void setTimeOffset(long pos) {
     seekOffset = (long)(pos / playbackSpeed);
-    if (seekOffset < timeOffset) {
-      seekBackwards = true;
+    long minJumpForwardOffset = timeOffset + (long)(10000 / playbackSpeed);
+    if (seekOffset < timeOffset || seekOffset >  minJumpForwardOffset) {
+      farSeeking = true;
     }
     notify();
   }
@@ -216,9 +217,9 @@
   // Methods for internal use.
   //
   private synchronized boolean fillBuffer() throws IOException {
-    // The reading thread should be interrupted on backward seeking.
-    if (seekBackwards)
-      throw new EOFException("[REWIND]");
+    // The reading thread should be interrupted on far seeking.
+    if (farSeeking)
+      throw new EOFException("[JUMP]");
 
     // Just wait unless we are performing playback OR seeking.
     waitWhilePaused();
diff --git a/java/src/com/tightvnc/rfbplayer/RfbPlayer.java b/java/src/com/tightvnc/rfbplayer/RfbPlayer.java
index 85d067d..6cdd386 100644
--- a/java/src/com/tightvnc/rfbplayer/RfbPlayer.java
+++ b/java/src/com/tightvnc/rfbplayer/RfbPlayer.java
@@ -180,8 +180,9 @@
           vc.processNormalProtocol();
         } catch (EOFException e) {
           long newTimeOffset;
-          if (e.getMessage() != null && e.getMessage().equals("[REWIND]")) {
-            // A special type of EOFException allowing us to seek backwards.
+          if (e.getMessage() != null && e.getMessage().equals("[JUMP]")) {
+            // A special type of EOFException allowing us to close FBS stream
+            // and then re-open it for jumping to a different time offset.
             newTimeOffset = fbs.getSeekOffset();
             autoPlay = !fbs.isPaused();
           } else {