[libbluray-devel] Status: release all listeners on shutdown
hpi1
git at videolan.org
Thu Apr 24 12:39:06 CEST 2014
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Thu Apr 24 12:46:22 2014 +0300| [6cf64446bc70026ffa6ab6db1b152a23dcf1c8c7] | committer: hpi1
Status: release all listeners on shutdown
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=6cf64446bc70026ffa6ab6db1b152a23dcf1c8c7
---
src/libbluray/bdj/java/org/bluray/bdplus/Status.java | 11 +++++++++++
src/libbluray/bdj/java/org/dvb/io/ixc/IxcRegistry.java | 13 ++++++-------
src/libbluray/bdj/java/org/videolan/BDJListeners.java | 10 ++++++++++
src/libbluray/bdj/java/org/videolan/Libbluray.java | 2 ++
4 files changed, 29 insertions(+), 7 deletions(-)
diff --git a/src/libbluray/bdj/java/org/bluray/bdplus/Status.java b/src/libbluray/bdj/java/org/bluray/bdplus/Status.java
index aa413ab..0d64f02 100644
--- a/src/libbluray/bdj/java/org/bluray/bdplus/Status.java
+++ b/src/libbluray/bdj/java/org/bluray/bdplus/Status.java
@@ -32,6 +32,17 @@ public class Status {
return instance;
}
+ public static void shutdown() {
+ Status s;
+ synchronized (Status.class) {
+ s = instance;
+ instance = null;
+ }
+ if (s != null) {
+ s.listeners.clear();
+ }
+ }
+
public void addListener(StatusListener listener) {
listeners.add(listener);
}
diff --git a/src/libbluray/bdj/java/org/dvb/io/ixc/IxcRegistry.java b/src/libbluray/bdj/java/org/dvb/io/ixc/IxcRegistry.java
index d68e1c1..8ad8e51 100644
--- a/src/libbluray/bdj/java/org/dvb/io/ixc/IxcRegistry.java
+++ b/src/libbluray/bdj/java/org/dvb/io/ixc/IxcRegistry.java
@@ -42,14 +42,13 @@ public class IxcRegistry {
}
public static void shutdown() {
+ IxcRegistryImpl r;
synchronized (IxcRegistry.class) {
- try {
- if (registry != null) {
- registry.unbindAll();
- }
- } finally {
- registry = null;
- }
+ r = registry;
+ registry = null;
+ }
+ if (r != null) {
+ r.unbindAll();
}
}
diff --git a/src/libbluray/bdj/java/org/videolan/BDJListeners.java b/src/libbluray/bdj/java/org/videolan/BDJListeners.java
index 796c65a..cd227c0 100644
--- a/src/libbluray/bdj/java/org/videolan/BDJListeners.java
+++ b/src/libbluray/bdj/java/org/videolan/BDJListeners.java
@@ -75,6 +75,16 @@ public class BDJListeners {
}
}
+ public void clear() {
+ if (null != BDJXletContext.getCurrentContext()) {
+ logger.error("clear() from wrong thread: " + Logger.dumpStack());
+ return;
+ }
+ synchronized (listeners) {
+ listeners.clear();
+ }
+ }
+
public void putCallback(Object event) {
synchronized (listeners) {
for (Iterator it = listeners.iterator(); it.hasNext(); ) {
diff --git a/src/libbluray/bdj/java/org/videolan/Libbluray.java b/src/libbluray/bdj/java/org/videolan/Libbluray.java
index 450299c..1be3794 100644
--- a/src/libbluray/bdj/java/org/videolan/Libbluray.java
+++ b/src/libbluray/bdj/java/org/videolan/Libbluray.java
@@ -28,6 +28,7 @@ import javax.media.PackageManager;
import javax.tv.service.SIManagerImpl;
import javax.tv.service.selection.ServiceContextFactory;
+import org.bluray.bdplus.Status;
import org.bluray.ti.DiscManager;
import org.bluray.ti.TitleImpl;
import org.bluray.ti.selection.TitleContext;
@@ -137,6 +138,7 @@ public class Libbluray {
BDToolkit.shutdownDisc();
SIManagerImpl.shutdown();
IxcRegistry.shutdown();
+ Status.shutdown();
} catch (Throwable e) {
e.printStackTrace();
}
More information about the libbluray-devel
mailing list