[Android] Medialibrary: Add args on current thread attach

Geoffrey Métais git at videolan.org
Tue Jul 24 10:50:46 CEST 2018


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

Medialibrary: Add args on current thread attach

(cherry picked from commit 07169605eeeefa6b291f72566783705905b7aa5f)

> https://code.videolan.org/videolan/vlc-android/commit/568b51220740d8b44c372f660cae0c07a7975b6d
---

 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 3d6805b5a..c6755fb7c 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
@@ -790,7 +791,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