[libbluray-devel] BD-J: Add separate event queue for media events.

hpi1 git at videolan.org
Sat Apr 4 19:20:35 CEST 2015


libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Sat Apr  4 20:08:59 2015 +0300| [5df9e3d6bfe2ee0745c990c1102ff7f59d5f52ec] | committer: hpi1

BD-J: Add separate event queue for media events.

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

 .../bdj/java/org/videolan/BDJListeners.java        |   33 ++++++++++++-
 .../bdj/java/org/videolan/BDJXletContext.java      |   52 +++++++++++---------
 2 files changed, 62 insertions(+), 23 deletions(-)

diff --git a/src/libbluray/bdj/java/org/videolan/BDJListeners.java b/src/libbluray/bdj/java/org/videolan/BDJListeners.java
index fb40399..f4b481f 100644
--- a/src/libbluray/bdj/java/org/videolan/BDJListeners.java
+++ b/src/libbluray/bdj/java/org/videolan/BDJListeners.java
@@ -92,6 +92,33 @@ public class BDJListeners {
     }
 
     public void putCallback(Object event) {
+        boolean mediaQueue = true;
+        /*
+        if (event instanceof PlaybackMarkEvent) {
+        } else if (event instanceof PlaybackPlayItemEvent) {
+        } else if (event instanceof UOMaskTableChangedEvent) {
+        } else if (event instanceof UOMaskedEvent) {
+        } else if (event instanceof PiPStatusEvent) {
+        } else if (event instanceof PanningChangeEvent) {
+        } else if (event instanceof AngleChangeEvent) {
+        } else if (event instanceof MediaSelectEvent) {
+        } else if (event instanceof GainChangeEvent) {
+        } else if (event instanceof ControllerEvent) {
+        }
+        */
+        if (event instanceof ServiceContextEvent) {
+            mediaQueue = false;
+        } else if (event instanceof ResourceStatusEvent) {
+            mediaQueue = false;
+        } else if (event instanceof AppsDatabaseEvent) {
+            mediaQueue = false;
+        } else if (event instanceof PSR102Status) {
+            mediaQueue = false;
+        }
+        putCallback(event, mediaQueue);
+    }
+
+    public void putCallback(Object event, boolean mediaQueue) {
         synchronized (listeners) {
             for (Iterator it = listeners.iterator(); it.hasNext(); ) {
                 BDJListener item = (BDJListener)it.next();
@@ -99,7 +126,11 @@ public class BDJListeners {
                     logger.info("Listener terminated: " + item.ctx);
                     it.remove();
                 } else {
-                    item.ctx.putCallback(new Callback(event, item.listener));
+                    if (mediaQueue) {
+                        item.ctx.putMediaCallback(new Callback(event, item.listener));
+                    } else {
+                        item.ctx.putCallback(new Callback(event, item.listener));
+                    }
                 }
             }
         }
diff --git a/src/libbluray/bdj/java/org/videolan/BDJXletContext.java b/src/libbluray/bdj/java/org/videolan/BDJXletContext.java
index 06a9ed4..def00fd 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");
+        mediaQueue = new BDJActionQueue(this.threadGroup, "MediaQueue");
         userEventQueue = new BDJActionQueue(this.threadGroup, "UserEventQueue");
 
         mountHomeDir(entry);
@@ -197,35 +198,39 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
         return eventQueue;
     }
 
+    /* must be called from synchronized (this) {} */
+    private boolean putCallbackImpl(BDJAction cb, BDJActionQueue queue)
+    {
+        if (isReleased()) {
+            logger.error("callback ignored (xlet destroyed)");
+            return false;
+        }
+        if (queue == null) {
+            logger.error("callback ignored (no queue)");
+            return false;
+        }
+        queue.put(cb);
+        return true;
+    }
+
     public boolean putCallback(BDJAction cb)
     {
         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 putCallbackImpl(cb, callbackQueue);
+        }
+    }
+
+    public boolean putMediaCallback(BDJAction cb)
+    {
+        synchronized (this) {
+            return putCallbackImpl(cb, mediaQueue);
         }
     }
 
     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;
+            return putCallbackImpl(cb, userEventQueue);
         }
     }
 
@@ -238,8 +243,8 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
             }
         }
         if (!released) {
-            // callbackQueue
-            cnt++;
+            // callbackQueue, userEventQueue, mediaQueue
+            cnt += 3;
         }
         return cnt;
     }
@@ -446,6 +451,7 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
 
         callbackQueue.shutdown();
         userEventQueue.shutdown();
+        mediaQueue.shutdown();
 
         EventQueue eq = eventQueue;
         eventQueue = null;
@@ -471,6 +477,7 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
             container = null;
             callbackQueue = null;
             userEventQueue = null;
+            mediaQueue = null;
             defaultLooks = null;
             released = true;
         }
@@ -495,5 +502,6 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
     private HashMap defaultLooks = new HashMap();
     private BDJActionQueue callbackQueue;
     private BDJActionQueue userEventQueue;
+    private BDJActionQueue mediaQueue;
     private static final Logger logger = Logger.getLogger(BDJXletContext.class.getName());
 }



More information about the libbluray-devel mailing list