libbluray | branch: master | hpi1 <[email protected]> | Sun May 17 12:55:19 2015 +0300| [8bb56b3a4ea0f49071bec7fae69f1d54369ed45a] | committer: hpi1
BD-J: cache parsed bdjo data Amount of data is small. Without caching it is loaded from disc multiple times. > http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=8bb56b3a4ea0f49071bec7fae69f1d54369ed45a --- src/libbluray/bdj/java/org/videolan/Libbluray.java | 25 +++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/libbluray/bdj/java/org/videolan/Libbluray.java b/src/libbluray/bdj/java/org/videolan/Libbluray.java index 41af18f..1a67fc9 100644 --- a/src/libbluray/bdj/java/org/videolan/Libbluray.java +++ b/src/libbluray/bdj/java/org/videolan/Libbluray.java @@ -24,6 +24,8 @@ import java.awt.BDFontMetrics; import java.awt.BDToolkit; import java.awt.event.KeyEvent; import java.io.File; +import java.util.HashMap; +import java.util.Map; import java.util.Vector; import javax.media.PackageManager; @@ -228,6 +230,7 @@ public class Libbluray { } nativePointer = 0; titleInfos = null; + bdjoFiles = null; } /* @@ -296,6 +299,10 @@ public class Libbluray { * Disc data */ + /* cache parsed .bdjo files */ + private static Map bdjoFiles = null; + private static Object bdjoFilesLock = new Object(); + public static byte[] getAacsData(int type) { return getAacsDataN(nativePointer, type); } @@ -305,7 +312,23 @@ public class Libbluray { } public static Bdjo getBdjo(String name) { - return getBdjoN(nativePointer, name + ".bdjo"); + Bdjo bdjo; + synchronized (bdjoFilesLock) { + if (bdjoFiles == null) { + bdjoFiles = new HashMap(); + } else { + bdjo = (Bdjo)bdjoFiles.get(name); + if (bdjo != null) { + return bdjo; + } + } + + bdjo = getBdjoN(nativePointer, name + ".bdjo"); + if (bdjo != null) { + bdjoFiles.put(name, bdjo); + } + return bdjo; + } } public static String[] listBdFiles(String path, boolean onlyBdRom) { _______________________________________________ libbluray-devel mailing list [email protected] https://mailman.videolan.org/listinfo/libbluray-devel
