[Android] jniloader: add more logs in case of error
Thomas Guillem
git at videolan.org
Fri Oct 27 18:11:36 CEST 2017
vlc-android | branch: master | Thomas Guillem <thomas at gllm.fr> | Fri Oct 27 18:04:43 2017 +0200| [3ebe1bcc30738adb3aa12a3e4a2805197fa01c66] | committer: Thomas Guillem
jniloader: add more logs in case of error
> https://code.videolan.org/videolan/vlc-android/commit/3ebe1bcc30738adb3aa12a3e4a2805197fa01c66
---
libvlc/jni/loader/Android.mk | 2 +-
libvlc/jni/loader/jniloader.c | 16 ++++++++++++++++
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/libvlc/jni/loader/Android.mk b/libvlc/jni/loader/Android.mk
index af74bcded..6d4b2530c 100644
--- a/libvlc/jni/loader/Android.mk
+++ b/libvlc/jni/loader/Android.mk
@@ -2,5 +2,5 @@ LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := jniloader
LOCAL_SRC_FILES := jniloader.c
-LOCAL_LDFLAGS := -ldl
+LOCAL_LDFLAGS := -ldl -llog
include $(BUILD_SHARED_LIBRARY)
diff --git a/libvlc/jni/loader/jniloader.c b/libvlc/jni/loader/jniloader.c
index 487a6d688..1b705f570 100644
--- a/libvlc/jni/loader/jniloader.c
+++ b/libvlc/jni/loader/jniloader.c
@@ -18,8 +18,12 @@
* Inc., 51 Franklin Street, Fifth Floor, Boston MA 02110-1301, USA.
*****************************************************************************/
#include <dlfcn.h>
+#include <android/log.h>
#include "jniloader.h"
+#define LOG_TAG "VLC"
+#define LOGE(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__)
+
/* jniloader.so is a shared C library used to receive JNI_OnLoad callback.
* Indeed, as JNI_OnLoad is already implemented in VLC core for its internal
* configuration, we can't have an other JNI_OnLoad implementation inside the
@@ -30,17 +34,29 @@ int JNI_OnLoad(JavaVM* vm, void* reserved)
JNIEnv *env;
if ((*vm)->GetEnv(vm, (void**) &env, VLC_JNI_VERSION) != JNI_OK)
+ {
+ LOGE("GetEnv failed");
return -1;
+ }
int (*load)(JavaVM *, JNIEnv*);
load = dlsym(RTLD_DEFAULT, "VLCJNI_OnLoad");
if (!load || load(vm, env) != 0)
+ {
+ if (!load)
+ LOGE("could not find VLCJNI_OnLoad");
+ else
+ LOGE("VLCJNI_OnLoad failed");
return -1;
+ }
/* MediaLibraryJNI_OnLoad is not mandatory */
load = dlsym(RTLD_DEFAULT, "MediaLibraryJNI_OnLoad");
if (load && load(vm, env) != 0)
+ {
+ LOGE("MediaLibraryJNI_OnLoad failed");
return -1;
+ }
return VLC_JNI_VERSION;
}
More information about the Android
mailing list