[libbluray-devel] BDJActionQueue: abort actions added after queue stop

hpi1 git at videolan.org
Mon Jan 20 14:39:42 CET 2014


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Mon Jan 20 15:27:34 2014 +0200| [f098fa16de5f03922bc3f90f16b09825582e9a0c] | committer: hpi1

BDJActionQueue: abort actions added after queue stop

> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=f098fa16de5f03922bc3f90f16b09825582e9a0c
---

 src/libbluray/bdj/java/org/videolan/BDJAction.java      |    7 +++++++
 src/libbluray/bdj/java/org/videolan/BDJActionQueue.java |   11 +++++++++--
 2 files changed, 16 insertions(+), 2 deletions(-)

diff --git a/src/libbluray/bdj/java/org/videolan/BDJAction.java b/src/libbluray/bdj/java/org/videolan/BDJAction.java
index a4be70e..ae157b6 100644
--- a/src/libbluray/bdj/java/org/videolan/BDJAction.java
+++ b/src/libbluray/bdj/java/org/videolan/BDJAction.java
@@ -66,6 +66,13 @@ public abstract class BDJAction {
         }
     }
 
+    public void abort() {
+        synchronized (this) {
+            state = PROCESSED;
+            this.notifyAll();
+        }
+    }
+
     protected abstract void doAction();
 
     private int state = NOT_PROCESSED;
diff --git a/src/libbluray/bdj/java/org/videolan/BDJActionQueue.java b/src/libbluray/bdj/java/org/videolan/BDJActionQueue.java
index 41969fc..07c314f 100644
--- a/src/libbluray/bdj/java/org/videolan/BDJActionQueue.java
+++ b/src/libbluray/bdj/java/org/videolan/BDJActionQueue.java
@@ -34,6 +34,7 @@ class BDJActionQueue implements Runnable {
 
     protected void finalize() throws Throwable {
         synchronized (actions) {
+            terminated = true;
             actions.addLast(null);
             actions.notifyAll();
         }
@@ -66,12 +67,18 @@ class BDJActionQueue implements Runnable {
     public void put(BDJAction action) {
         if (action != null) {
             synchronized (actions) {
-                actions.addLast(action);
-                actions.notifyAll();
+                if (!terminated) {
+                    actions.addLast(action);
+                    actions.notifyAll();
+                } else {
+                    Logger.getLogger(BDJActionQueue.class.getName()).error("Action skipped (queue stopped): " + action);
+                    action.abort();
+                }
             }
         }
     }
 
+    private boolean terminated = false;
     private Thread thread;
     private LinkedList actions = new LinkedList();
 }



More information about the libbluray-devel mailing list