[libbluray-devel] Use separate event queue for user events.

hpi1 git at videolan.org
Wed Feb 25 14:46:45 CET 2015


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Wed Feb 25 15:34:10 2015 +0200| [74dbafb15dafb7f3c7c663d8e08af883dbd90a93] | committer: hpi1

Use separate event queue for user events.

Fixes "The Help"

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

 .../bdj/java/org/dvb/event/EventManager.java       |    4 ++--
 .../bdj/java/org/videolan/BDJXletContext.java      |   20 ++++++++++++++++++++
 2 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/src/libbluray/bdj/java/org/dvb/event/EventManager.java b/src/libbluray/bdj/java/org/dvb/event/EventManager.java
index a3c8bf3..2bf2ea4 100644
--- a/src/libbluray/bdj/java/org/dvb/event/EventManager.java
+++ b/src/libbluray/bdj/java/org/dvb/event/EventManager.java
@@ -178,7 +178,7 @@ public class EventManager implements ResourceServer {
                 continue;
             }
             if (item.userEvents.contains(ue)) {
-                item.context.putCallback(new UserEventAction(item, ue));
+                item.context.putUserEvent(new UserEventAction(item, ue));
                 return true;
             }
         }
@@ -193,7 +193,7 @@ public class EventManager implements ResourceServer {
                 continue;
             }
             if (item.userEvents.contains(ue)) {
-                item.context.putCallback(new UserEventAction(item, ue));
+                item.context.putUserEvent(new UserEventAction(item, ue));
                 result = true;
             }
         }
diff --git a/src/libbluray/bdj/java/org/videolan/BDJXletContext.java b/src/libbluray/bdj/java/org/videolan/BDJXletContext.java
index 55fe985..b76c8cc 100644
--- a/src/libbluray/bdj/java/org/videolan/BDJXletContext.java
+++ b/src/libbluray/bdj/java/org/videolan/BDJXletContext.java
@@ -55,6 +55,7 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
                                               this);
 
         callbackQueue = new BDJActionQueue(this.threadGroup, "CallbackQueue");
+        userEventQueue = new BDJActionQueue(this.threadGroup, "UserEventQueue");
 
         mountHomeDir(entry);
     }
@@ -206,6 +207,22 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
         }
     }
 
+    public boolean putUserEvent(BDJAction cb)
+    {
+        synchronized (this) {
+            if (isReleased()) {
+                logger.error("UE callback ignored (xlet destroyed)");
+                return false;
+            }
+            if (userEventQueue == null) {
+                logger.error("UE callback ignored (no queue)");
+                return false;
+            }
+            userEventQueue.put(cb);
+            return true;
+        }
+    }
+
     protected int numEventQueueThreads() {
         int cnt = 0;
         if (eventQueue != null) {
@@ -422,6 +439,7 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
         }
 
         callbackQueue.shutdown();
+        userEventQueue.shutdown();
 
         EventQueue eq = eventQueue;
         eventQueue = null;
@@ -446,6 +464,7 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
             loader = null;
             container = null;
             callbackQueue = null;
+            userEventQueue = null;
             defaultLooks = null;
             released = true;
         }
@@ -469,5 +488,6 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
     private BDJSockets sockets = new BDJSockets();
     private HashMap defaultLooks = new HashMap();
     private BDJActionQueue callbackQueue;
+    private BDJActionQueue userEventQueue;
     private static final Logger logger = Logger.getLogger(BDJXletContext.class.getName());
 }



More information about the libbluray-devel mailing list