[Android] Medialibrary: Add args on current thread attach

Geoffrey Métais git at videolan.org
Mon Jul 23 15:58:01 CEST 2018


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Jul 23 15:21:21 2018 +0200| [07169605eeeefa6b291f72566783705905b7aa5f] | committer: Geoffrey Métais

Medialibrary: Add args on current thread attach

> https://code.videolan.org/videolan/vlc-android/commit/07169605eeeefa6b291f72566783705905b7aa5f
---

 medialibrary/jni/AndroidMediaLibrary.cpp | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/medialibrary/jni/AndroidMediaLibrary.cpp b/medialibrary/jni/AndroidMediaLibrary.cpp
index 464f23efe..eaef0e756 100644
--- a/medialibrary/jni/AndroidMediaLibrary.cpp
+++ b/medialibrary/jni/AndroidMediaLibrary.cpp
@@ -2,6 +2,7 @@
 #define LOG_TAG "VLC/JNI/AndroidMediaLibrary"
 #include "log.h"
 #include "jniloader.h"
+#define THREAD_NAME "AndroidMedialibrary"
 
 #define FLAG_MEDIA_UPDATED_AUDIO       1 << 0
 #define FLAG_MEDIA_UPDATED_AUDIO_EMPTY 1 << 1
@@ -732,7 +733,12 @@ AndroidMediaLibrary::getEnv() {
         case JNI_OK:
             break;
         case JNI_EDETACHED:
-            if (myVm->AttachCurrentThread(&env, NULL) != JNI_OK)
+            /* attach the thread to the Java VM */
+            JavaVMAttachArgs args;
+            args.version = VLC_JNI_VERSION;
+            args.name = THREAD_NAME;
+            args.group = NULL;
+            if (myVm->AttachCurrentThread(&env, &args) != JNI_OK)
                 return NULL;
             if (pthread_setspecific(jni_env_key, env) != 0)
             {



More information about the Android mailing list