提交 bc58a50c 编写于 作者: Z Zhang Rui

android: optional library load

上级 977aba8a
......@@ -54,10 +54,6 @@ public final class IjkMediaPlayer extends SimpleMediaPlayer {
protected static final int MEDIA_SET_VIDEO_SAR = 10001;
static {
native_init();
}
@AccessedByNative
private long mNativeMediaPlayer;
......@@ -85,7 +81,7 @@ public final class IjkMediaPlayer extends SimpleMediaPlayer {
* Load them by yourself, if your libraries are not installed at default place.
*/
private static volatile boolean mIsLibLoaded = false;
public static void loadLibraries() {
public static void loadLibrariesOnce() {
synchronized (IjkMediaPlayer.class) {
if (!mIsLibLoaded) {
System.loadLibrary("stlport_shared");
......@@ -98,6 +94,16 @@ public final class IjkMediaPlayer extends SimpleMediaPlayer {
}
}
private static volatile boolean mIsNativeInitialized = false;
private static void initNativeOnce() {
synchronized (IjkMediaPlayer.class) {
if (!mIsNativeInitialized) {
native_init();
mIsNativeInitialized = true;
}
}
}
public enum InitMode {
Default, CustomLibrary
}
......@@ -125,8 +131,9 @@ public final class IjkMediaPlayer extends SimpleMediaPlayer {
private void initPlayer(InitMode initMode) {
if (initMode != InitMode.CustomLibrary) {
loadLibraries();
loadLibrariesOnce();
}
initNativeOnce();
Looper looper;
if ((looper = Looper.myLooper()) != null) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册