[Android] Merge setup and init methods for Medialibrary

Geoffrey Métais git at videolan.org
Fri May 19 11:19:40 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri May 19 10:52:39 2017 +0200| [315b8cf5efd336f427e63a7568d7099ebb66eb40] | committer: Geoffrey Métais

Merge setup and init methods for Medialibrary

> https://code.videolan.org/videolan/vlc-android/commit/315b8cf5efd336f427e63a7568d7099ebb66eb40
---

 medialibrary/jni/medialibrary.cpp                            | 10 ++--------
 medialibrary/src/org/videolan/medialibrary/Medialibrary.java |  5 -----
 vlc-android/src/org/videolan/vlc/MediaParsingService.java    |  1 -
 3 files changed, 2 insertions(+), 14 deletions(-)

diff --git a/medialibrary/jni/medialibrary.cpp b/medialibrary/jni/medialibrary.cpp
index e78d597..2791e4b 100644
--- a/medialibrary/jni/medialibrary.cpp
+++ b/medialibrary/jni/medialibrary.cpp
@@ -22,18 +22,13 @@ AndroidMediaLibrary *MediaLibrary_getInstance(JNIEnv *env, jobject thiz);
 static void
 MediaLibrary_setInstance(JNIEnv *env, jobject thiz, AndroidMediaLibrary *p_obj);
 
-void
-setup(JNIEnv* env, jobject thiz) {
-    AndroidMediaLibrary *aml = new  AndroidMediaLibrary(myVm, &ml_fields, thiz);
-    MediaLibrary_setInstance(env, thiz, aml);
-}
-
 jboolean
 init(JNIEnv* env, jobject thiz, jstring dbPath, jstring thumbsPath)
 {
+    AndroidMediaLibrary *aml = new  AndroidMediaLibrary(myVm, &ml_fields, thiz);
+    MediaLibrary_setInstance(env, thiz, aml);
     const char *db_utfchars = env->GetStringUTFChars(dbPath, JNI_FALSE);
     const char *thumbs_utfchars = env->GetStringUTFChars(thumbsPath, JNI_FALSE);
-    AndroidMediaLibrary *aml = MediaLibrary_getInstance(env, thiz);
     m_IsInitialized = aml->initML(db_utfchars, thumbs_utfchars);
     env->ReleaseStringUTFChars(dbPath, db_utfchars);
     env->ReleaseStringUTFChars(thumbsPath, thumbs_utfchars);
@@ -741,7 +736,6 @@ playlistDelete(JNIEnv* env, jobject thiz, jobject medialibrary, jlong playlistId
   * JNI stuff
   */
 static JNINativeMethod methods[] = {
-    {"nativeSetup", "()V", (void*)setup },
     {"nativeInit", "(Ljava/lang/String;Ljava/lang/String;)Z", (void*)init },
     {"nativeStart", "()V", (void*)start },
     {"nativeRelease", "()V", (void*)release },
diff --git a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
index 1113412..25c6396 100644
--- a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
@@ -72,10 +72,6 @@ public class Medialibrary {
         System.loadLibrary("mla");
     }
 
-    public void setup() {
-        nativeSetup();
-    }
-
     public boolean init(Context context) {
         mIsInitiated = nativeInit(context.getCacheDir()+ VLC_MEDIA_DB_NAME, context.getExternalFilesDir(null).getAbsolutePath()+ THUMBS_FOLDER_NAME);
         return mIsInitiated;
@@ -552,7 +548,6 @@ public class Medialibrary {
 
 
     // Native methods
-    private native void nativeSetup();
     private native boolean nativeInit(String dbPath, String thumbsPath);
     private native void nativeStart();
     private native void nativeRelease();
diff --git a/vlc-android/src/org/videolan/vlc/MediaParsingService.java b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
index c4fcfa3..ad9f65e 100644
--- a/vlc-android/src/org/videolan/vlc/MediaParsingService.java
+++ b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
@@ -199,7 +199,6 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
                 @Override
                 public void run() {
                     boolean shouldInit = !(new File(MediaParsingService.this.getCacheDir()+Medialibrary.VLC_MEDIA_DB_NAME).exists());
-                    mMedialibrary.setup();
                     if (mMedialibrary.init(VLCApplication.getAppContext())) {
                         List<String> devices = new ArrayList<>();
                         devices.add(AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY);



More information about the Android mailing list