Skip to content
Snippets Groups Projects
Commit ae6c6a30 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Harden Medialibrary initialization

(cherry picked from commit ad48e895)
parent fce11dee
No related branches found
No related tags found
No related merge requests found
......@@ -29,8 +29,10 @@ import org.videolan.medialibrary.stubs.StubPlaylist;
public class MLServiceLocator {
private static LocatorMode sMode = LocatorMode.VLC_ANDROID;
private static volatile AbstractMedialibrary instance;
public static void setLocatorMode(LocatorMode mode) {
if (instance != null) throw new IllegalStateException("LocatorMode must be set before AbstractMedialibrary initialization");
MLServiceLocator.sMode = mode;
}
......@@ -40,12 +42,11 @@ public class MLServiceLocator {
TESTS,
}
public static AbstractMedialibrary getAbstractMedialibrary() {
if (sMode == LocatorMode.VLC_ANDROID) {
return new Medialibrary();
} else {
return new StubMedialibrary();
public static synchronized AbstractMedialibrary getAbstractMedialibrary() {
if (instance == null) {
instance = sMode == LocatorMode.VLC_ANDROID ? new Medialibrary() : new StubMedialibrary();
}
return instance;
}
// AbstractMediaWrapper
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment