[libbluray-devel] BD-J: Split Xlet context release to in-xlet and privileged parts

hpi1 git at videolan.org
Wed Mar 23 11:54:05 CET 2016


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Wed Mar 23 12:07:10 2016 +0200| [3f790aa0e16fdec12e37fb5292643fee7eea4404] | committer: hpi1

BD-J: Split Xlet context release to in-xlet and privileged parts

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

 src/libbluray/bdj/java/org/videolan/BDJAppProxy.java    |    2 ++
 src/libbluray/bdj/java/org/videolan/BDJXletContext.java |   15 ++++++++++++---
 .../bdj/java/org/videolan/IxcRegistryImpl.java          |    4 ++--
 3 files changed, 16 insertions(+), 5 deletions(-)

diff --git a/src/libbluray/bdj/java/org/videolan/BDJAppProxy.java b/src/libbluray/bdj/java/org/videolan/BDJAppProxy.java
index b5dfcf6..1bacac0 100644
--- a/src/libbluray/bdj/java/org/videolan/BDJAppProxy.java
+++ b/src/libbluray/bdj/java/org/videolan/BDJAppProxy.java
@@ -252,6 +252,8 @@ class BDJAppProxy implements DVBJProxy, Runnable {
                 context.closeSockets();
                 context.getThreadGroup().waitForShutdown(1000, 1 + context.numEventQueueThreads());
 
+                context.exitXlet();
+
             } catch (Throwable e) {
                 logger.error("doStop() failed: " + e + "\n" + Logger.dumpStack(e));
                 state = INVALID;
diff --git a/src/libbluray/bdj/java/org/videolan/BDJXletContext.java b/src/libbluray/bdj/java/org/videolan/BDJXletContext.java
index 8ee818a..7a84ea0 100644
--- a/src/libbluray/bdj/java/org/videolan/BDJXletContext.java
+++ b/src/libbluray/bdj/java/org/videolan/BDJXletContext.java
@@ -444,19 +444,28 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
                 entry.getInitialClass());
     }
 
-    protected void release() {
+    protected void exitXlet() {
+        // called from Xlet context when destroyXlet() has been returned.
+        // release as much resources as possible.
+        // Avoid releasing resources from privileged context (callbacks)
+
+        org.dvb.io.ixc.IxcRegistry.unbindAll(this);
 
         closeSockets();
         removeAllFAA();
         stopIxcThreads();
-        defaultLooks.clear();
 
-        org.dvb.io.ixc.IxcRegistry.unbindAll(this);
+        defaultLooks.clear();
 
         if (sceneFactory != null) {
             sceneFactory.dispose();
             sceneFactory = null;
         }
+    }
+
+    protected void release() {
+
+        exitXlet();
 
         callbackQueue.shutdown();
         userEventQueue.shutdown();
diff --git a/src/libbluray/bdj/java/org/videolan/IxcRegistryImpl.java b/src/libbluray/bdj/java/org/videolan/IxcRegistryImpl.java
index bae986f..2413c2d 100644
--- a/src/libbluray/bdj/java/org/videolan/IxcRegistryImpl.java
+++ b/src/libbluray/bdj/java/org/videolan/IxcRegistryImpl.java
@@ -510,8 +510,8 @@ public class IxcRegistryImpl {
     }
 
     public void unbindAll(XletContext xc) {
-
-        if (null != BDJXletContext.getCurrentContext()) {
+        XletContext requestor = BDJXletContext.getCurrentContext();
+        if (requestor != null && requestor != xc) {
             logger.error("unbindAll(ctx) from wrong thread: " + Logger.dumpStack());
             return;
         }



More information about the libbluray-devel mailing list