Fix RfbPlayer so that it shuts down more orderly. prevents a
crash with certain jvm versions under Win IE.
git-svn-id: svn://svn.code.sf.net/p/tigervnc/code/trunk@2538 3789f03b-4d11-0410-bbf8-ca57d06f2519
diff --git a/java/src/com/tightvnc/rfbplayer/FbsInputStream.java b/java/src/com/tightvnc/rfbplayer/FbsInputStream.java
index 5547c3c..6df38dd 100644
--- a/java/src/com/tightvnc/rfbplayer/FbsInputStream.java
+++ b/java/src/com/tightvnc/rfbplayer/FbsInputStream.java
@@ -34,6 +34,7 @@
protected long seekOffset;
protected boolean seekBackwards;
protected boolean paused;
+ protected boolean isQuitting = false;
protected double playbackSpeed;
protected byte[] buffer;
@@ -76,6 +77,14 @@
bufferPos = 0;
}
+ // Force stream to finish any wait.
+ public void quit() {
+ isQuitting = true;
+ synchronized(this) {
+ notify();
+ }
+ }
+
//
// Basic methods overriding InputStream's methods.
//
@@ -202,7 +211,7 @@
}
}
- while (true) {
+ while (!isQuitting) {
long timeDiff = startTime + timeOffset - System.currentTimeMillis();
if (timeDiff <= 0) {
break;
@@ -221,7 +230,7 @@
// In paused mode, wait for external notification on this object.
//
private void waitWhilePaused() {
- while (paused && !isSeeking()) {
+ while (paused && !isSeeking() && !isQuitting) {
synchronized(this) {
try {
// Note: we call Observer.update(Observable,Object) method