[libbluray-devel] Added BDJXletContext.isReleased()

hpi1 git at videolan.org
Thu Jan 16 20:37:54 CET 2014


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Wed Jan 15 13:31:28 2014 +0200| [0564d4fc3e7b8edd52978e69cdbc1f18f93adfbf] | committer: hpi1

Added BDJXletContext.isReleased()

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

 .../bdj/java/org/dvb/event/EventManager.java       |    9 +++--
 .../bdj/java/org/videolan/BDJListeners.java        |    2 +-
 .../bdj/java/org/videolan/BDJXletContext.java      |   39 ++++++++++++++++----
 .../bdj/java/org/videolan/IxcRegistryImpl.java     |    6 +--
 4 files changed, 41 insertions(+), 15 deletions(-)

diff --git a/src/libbluray/bdj/java/org/dvb/event/EventManager.java b/src/libbluray/bdj/java/org/dvb/event/EventManager.java
index 36fde6f..773cd29 100644
--- a/src/libbluray/bdj/java/org/dvb/event/EventManager.java
+++ b/src/libbluray/bdj/java/org/dvb/event/EventManager.java
@@ -140,7 +140,8 @@ public class EventManager implements ResourceServer {
             BDJXletContext context = focusHScene.getXletContext();
             for (Iterator it = exclusiveAWTEventListener.iterator(); it.hasNext(); ) {
                 UserEventItem item = (UserEventItem)it.next();
-                if (item.context == null) {
+                if (item.context == null || item.context.isReleased()) {
+                    logger.error("Removing exclusive AWT event listener for " + item.context);
                     it.remove();
                     continue;
                 }
@@ -155,7 +156,8 @@ public class EventManager implements ResourceServer {
 
         for (Iterator it = exclusiveUserEventListener.iterator(); it.hasNext(); ) {
             UserEventItem item = (UserEventItem)it.next();
-            if (item.context == null) {
+            if (item.context == null || item.context.isReleased()) {
+                logger.error("Removing exclusive UserEvent listener for " + item.context);
                 it.remove();
                 continue;
             }
@@ -169,7 +171,8 @@ public class EventManager implements ResourceServer {
 
         for (Iterator it = sharedUserEventListener.iterator(); it.hasNext(); ) {
             UserEventItem item = (UserEventItem)it.next();
-            if (item.context == null) {
+            if (item.context == null || item.context.isReleased()) {
+                logger.error("Removing UserEvent listener for " + item.context);
                 it.remove();
                 continue;
             }
diff --git a/src/libbluray/bdj/java/org/videolan/BDJListeners.java b/src/libbluray/bdj/java/org/videolan/BDJListeners.java
index ab86a03..91e2209 100644
--- a/src/libbluray/bdj/java/org/videolan/BDJListeners.java
+++ b/src/libbluray/bdj/java/org/videolan/BDJListeners.java
@@ -78,7 +78,7 @@ public class BDJListeners {
                 if (item.ctx == null) {
                     logger.error("Listener callback: no context: " + item.listener);
                     it.remove();
-                } else if (item.ctx.isDestroyed()) {
+                } else if (item.ctx.isReleased()) {
                     logger.error("Listener terminated: " + item.ctx);
                     it.remove();
                 } else {
diff --git a/src/libbluray/bdj/java/org/videolan/BDJXletContext.java b/src/libbluray/bdj/java/org/videolan/BDJXletContext.java
index 48f1c0b..09aaf43 100644
--- a/src/libbluray/bdj/java/org/videolan/BDJXletContext.java
+++ b/src/libbluray/bdj/java/org/videolan/BDJXletContext.java
@@ -101,9 +101,18 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
         return AppsDatabase.getAppsDatabase().getAppProxy(appid);
     }
 
+    public boolean isReleased() {
+        return released;
+    }
+
+    /*
     public boolean isDestroyed() {
-        return AppsDatabase.getAppsDatabase().getAppProxy(appid).getState() == AppProxy.DESTROYED;
+        if (released)
+            return true;
+        AppProxy proxy = AppsDatabase.getAppsDatabase().getAppProxy(appid);
+        return proxy == null || proxy.getState() == AppProxy.DESTROYED;
     }
+    */
 
     public BDJThreadGroup getThreadGroup() {
         return threadGroup;
@@ -119,11 +128,18 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
 
     public boolean putCallback(BDJAction cb)
     {
-        if (!isDestroyed()) {
+        synchronized (this) {
+            if (isReleased()) {
+                logger.error("callback ignored (xlet destroyed)");
+                return false;
+            }
+            if (callbackQueue == null) {
+                logger.error("callback ignored (no queue)");
+                return false;
+            }
             callbackQueue.put(cb);
             return true;
         }
-        return false;
     }
 
     protected int numEventQueueThreads() {
@@ -134,6 +150,10 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
                 cnt++;
             }
         }
+        if (!released) {
+            // callbackQueue
+            cnt++;
+        }
         return cnt;
     }
 
@@ -242,8 +262,6 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
         try {
             callbackQueue.finalize();
         } catch (Throwable t) {
-        } finally {
-            //callbackQueue = null;
         }
 
         EventQueue eq = eventQueue;
@@ -254,11 +272,16 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
 
         threadGroup.stopAll(1000);
 
-        threadGroup = null;
-        loader = null;
-        container = null;
+        synchronized (this) {
+            threadGroup = null;
+            loader = null;
+            container = null;
+            callbackQueue = null;
+            released = true;
+        }
     }
 
+    private boolean released = false;
     private String[] args;
     private AppID appid;
     private BDJClassLoader loader;
diff --git a/src/libbluray/bdj/java/org/videolan/IxcRegistryImpl.java b/src/libbluray/bdj/java/org/videolan/IxcRegistryImpl.java
index a9ed8da..8c2b9b9 100644
--- a/src/libbluray/bdj/java/org/videolan/IxcRegistryImpl.java
+++ b/src/libbluray/bdj/java/org/videolan/IxcRegistryImpl.java
@@ -208,7 +208,7 @@ public class IxcRegistryImpl {
         }
 
         public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
-            if (null == remoteObj.context || remoteObj.context.isDestroyed()) {
+            if (null == remoteObj.context || remoteObj.context.isReleased()) {
                 Debug("invoke(): callee has been destroyed");
                 throw new RemoteException("callee has been destroyed");
             }
@@ -226,7 +226,7 @@ public class IxcRegistryImpl {
 
             RemoteMethod remoteMethod = new RemoteMethod(method, remoteObj.context, args);
 
-            if (remoteMethod.callerContext.isDestroyed()) {
+            if (remoteMethod.callerContext.isReleased()) {
                 Debug("invoke(): caller has been destroyed");
                 throw new RemoteException("caller has been destroyed");
             }
@@ -393,7 +393,7 @@ public class IxcRegistryImpl {
             Debug("bind(): xc not current BDJXletContext");
             throw new IllegalArgumentException("xc not current BDJXletContext");
         }
-        if (((BDJXletContext)xc).isDestroyed()) {
+        if (((BDJXletContext)xc).isReleased()) {
             Debug("bind(): xc is destroyed");
             return;
         }



More information about the libbluray-devel mailing list