[libbluray-devel] Stop frame-accurate animations when xlet terminates
hpi1
git at videolan.org
Tue Dec 10 13:15:41 CET 2013
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Tue Dec 10 13:26:20 2013 +0200| [792bc0b16a324b8541caa412e88847ab42040a4e] | committer: hpi1
Stop frame-accurate animations when xlet terminates
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=792bc0b16a324b8541caa412e88847ab42040a4e
---
.../java/org/bluray/ui/FrameAccurateAnimation.java | 14 ++++++++++
.../bdj/java/org/videolan/BDJXletContext.java | 27 ++++++++++++++++++++
2 files changed, 41 insertions(+)
diff --git a/src/libbluray/bdj/java/org/bluray/ui/FrameAccurateAnimation.java b/src/libbluray/bdj/java/org/bluray/ui/FrameAccurateAnimation.java
index 41b34f1..12f3008 100644
--- a/src/libbluray/bdj/java/org/bluray/ui/FrameAccurateAnimation.java
+++ b/src/libbluray/bdj/java/org/bluray/ui/FrameAccurateAnimation.java
@@ -23,6 +23,7 @@ package org.bluray.ui;
import java.awt.Component;
import java.awt.Graphics;
+import org.videolan.BDJXletContext;
import org.videolan.Logger;
public abstract class FrameAccurateAnimation extends Component {
@@ -55,11 +56,23 @@ public abstract class FrameAccurateAnimation extends Component {
public FrameAccurateAnimation(AnimationParameters params)
{
+ context = BDJXletContext.getCurrentContext();
+ if (context != null) {
+ context.addFAA(this);
+ } else {
+ logger.error("FrameAccurateAnimation created from wrong thread: " + logger.dumpStack());
+ }
+
this.params = new AnimationParameters(params);
}
public synchronized void destroy()
{
+ if (context != null) {
+ context.removeFAA(this);
+ context = null;
+ }
+
destroyImpl();
}
@@ -171,6 +184,7 @@ public abstract class FrameAccurateAnimation extends Component {
return "FrameAccurateAnimation";
}
+ private BDJXletContext context;
protected boolean running;
protected AnimationParameters params;
diff --git a/src/libbluray/bdj/java/org/videolan/BDJXletContext.java b/src/libbluray/bdj/java/org/videolan/BDJXletContext.java
index f1961f5..48f1c0b 100644
--- a/src/libbluray/bdj/java/org/videolan/BDJXletContext.java
+++ b/src/libbluray/bdj/java/org/videolan/BDJXletContext.java
@@ -27,6 +27,7 @@ import java.security.PrivilegedAction;
import javax.microedition.xlet.UnavailableContainerException;
+import org.bluray.ui.FrameAccurateAnimation;
import org.dvb.application.AppID;
import org.dvb.application.AppProxy;
import org.dvb.application.AppsDatabase;
@@ -174,6 +175,29 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
}
}
+ public void addFAA(FrameAccurateAnimation faa) {
+ synchronized (faaList) {
+ faaList.add(faa);
+ }
+ }
+
+ public void removeFAA(FrameAccurateAnimation faa) {
+ synchronized (faaList) {
+ faaList.remove(faa);
+ }
+ }
+
+ public void removeAllFAA() {
+ Object[] faaArray;
+ synchronized (faaList) {
+ faaArray = faaList.toArray();
+ }
+ for (int i = 0; i < faaArray.length; i++) {
+ FrameAccurateAnimation faa = (FrameAccurateAnimation)faaArray[i];
+ faa.destroy();
+ }
+ }
+
public static BDJXletContext getCurrentContext() {
Object obj = AccessController.doPrivileged(
new PrivilegedAction() {
@@ -204,6 +228,8 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
}
protected void release() {
+
+ removeAllFAA();
stopIxcThreads();
org.dvb.io.ixc.IxcRegistry.unbindAll(this);
@@ -241,6 +267,7 @@ public class BDJXletContext implements javax.tv.xlet.XletContext, javax.microedi
private HSceneFactory sceneFactory = null;
private BDJThreadGroup threadGroup = null;
private LinkedList ixcThreads = new LinkedList();
+ private LinkedList faaList = new LinkedList();
private BDJActionQueue callbackQueue;
private static final Logger logger = Logger.getLogger(BDJXletContext.class.getName());
}
More information about the libbluray-devel
mailing list