[libbluray-devel] Add locking for titleInfos
hpi1
git at videolan.org
Sun Feb 19 12:27:38 CET 2017
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Tue Jan 10 10:24:59 2017 +0200| [0292947c89815d24188aac143bf1885beed1afbd] | committer: hpi1
Add locking for titleInfos
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=0292947c89815d24188aac143bf1885beed1afbd
---
src/libbluray/bdj/java/org/videolan/Libbluray.java | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/src/libbluray/bdj/java/org/videolan/Libbluray.java b/src/libbluray/bdj/java/org/videolan/Libbluray.java
index 3bc0143..dead64b 100644
--- a/src/libbluray/bdj/java/org/videolan/Libbluray.java
+++ b/src/libbluray/bdj/java/org/videolan/Libbluray.java
@@ -277,7 +277,9 @@ public class Libbluray {
System.err.println("shutdown() failed: " + e + "\n" + Logger.dumpStack(e));
}
nativePointer = 0;
- titleInfos = null;
+ synchronized (titleInfosLock) {
+ titleInfos = null;
+ }
synchronized (bdjoFilesLock) {
bdjoFiles = null;
}
@@ -314,6 +316,7 @@ public class Libbluray {
/* used by javax/tv/service/SIManagerImpl */
public static int numTitles() {
+ synchronized (titleInfosLock) {
if (titleInfos == null) {
titleInfos = getTitleInfosN(nativePointer);
if (titleInfos == null) {
@@ -321,10 +324,12 @@ public class Libbluray {
}
}
return titleInfos.length - 2;
+ }
}
/* used by org/bluray/ti/TitleImpl */
public static TitleInfo getTitleInfo(int titleNum) {
+ synchronized (titleInfosLock) {
int numTitles = numTitles();
if (numTitles < 0)
return null;
@@ -337,6 +342,7 @@ public class Libbluray {
throw new IllegalArgumentException();
return titleInfos[titleNum];
+ }
}
/* used by org/bluray/ti/PlayListImpl */
@@ -727,5 +733,6 @@ public class Libbluray {
int x0, int y0, int x1, int y1);
private static long nativePointer = 0;
+ private static Object titleInfosLock = new Object();
private static TitleInfo[] titleInfos = null;
}
More information about the libbluray-devel
mailing list