[libbluray-devel] FontFactory: clean up locking
hpi1
git at videolan.org
Tue Mar 29 12:50:53 CEST 2016
libbluray | branch: master | hpi1 <hpi1 at anonymous.org> | Tue Mar 29 11:33:15 2016 +0300| [8a4d1b4eb647f531c44184ea3a9de0fe9449a1a0] | committer: hpi1
FontFactory: clean up locking
> http://git.videolan.org/gitweb.cgi/libbluray.git/?a=commit;h=8a4d1b4eb647f531c44184ea3a9de0fe9449a1a0
---
src/libbluray/bdj/java/org/dvb/ui/FontFactory.java | 24 +++++++++++++-------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/src/libbluray/bdj/java/org/dvb/ui/FontFactory.java b/src/libbluray/bdj/java/org/dvb/ui/FontFactory.java
index 3b0c913..ab3ab4b 100644
--- a/src/libbluray/bdj/java/org/dvb/ui/FontFactory.java
+++ b/src/libbluray/bdj/java/org/dvb/ui/FontFactory.java
@@ -34,16 +34,22 @@ import org.videolan.FontIndexData;
import org.videolan.Logger;
public class FontFactory {
- public static synchronized void loadDiscFonts() {
+ public static void loadDiscFonts() {
unloadDiscFonts();
+
+ // fonts are loaded on demand
}
- public static synchronized void unloadDiscFonts() {
- fonts = null;
- fontIds = null;
+ public static void unloadDiscFonts() {
+ synchronized (fontsLock) {
+ fonts = null;
+ fontIds = null;
+ }
}
- private static synchronized void readDiscFonts() throws FontFormatException, IOException {
+ private static void readDiscFonts() throws FontFormatException, IOException {
+ synchronized (fontsLock) {
+
if (fonts != null)
return;
@@ -84,7 +90,7 @@ public class FontFactory {
}
}
}
-
+ }
}
public FontFactory() throws FontFormatException, IOException {
@@ -120,7 +126,7 @@ public class FontFactory {
public Font createFont(String fontId) {
Font font = null;
- synchronized (FontFactory.class) {
+ synchronized (fontsLock) {
font = (Font)fontIds.get(fontId);
}
if (font != null) {
@@ -148,7 +154,7 @@ public class FontFactory {
/* Factory created for fonts in dvb.fontindex */
Font font = null;
- synchronized (FontFactory.class) {
+ synchronized (fontsLock) {
font = (Font)fonts.get(name + "." + style);
}
@@ -162,6 +168,8 @@ public class FontFactory {
private Font urlFont = null;
+ private static final Object fontsLock = new Object();
+
private static Map fonts = null;
private static Map fontIds = null;
More information about the libbluray-devel
mailing list