[Android] Use libvlc_log_*() instead of logger module

Rafaël Carré git at videolan.org
Mon May 14 19:07:21 CEST 2012


android | branch: master | Rafaël Carré <funman at videolan.org> | Sun May 13 18:35:30 2012 -0400| [16a2b640cba34dfa0c2128d2734e1b394ec9b190] | committer: Rafaël Carré

Use libvlc_log_*() instead of logger module

> http://git.videolan.org/gitweb.cgi/android.git/?a=commit;h=16a2b640cba34dfa0c2128d2734e1b394ec9b190
---

 Makefile                    |    2 +-
 vlc-android/jni/libvlcjni.c |   26 ++++++++++++++++++++++++--
 2 files changed, 25 insertions(+), 3 deletions(-)

diff --git a/Makefile b/Makefile
index 54a5002..a2de793 100644
--- a/Makefile
+++ b/Makefile
@@ -36,7 +36,7 @@ $(VLC_APK): $(LIBVLCJNI) $(JAVA_SOURCES)
 	@echo
 	$(VERBOSE)cd $(SRC) && ant $(ANT_OPTS) debug
 
-VLC_MODULES=`find $(VLC_BUILD_DIR)/modules -name 'lib*_plugin.a'|grep -v -E "stats|access_bd|oldrc|real|hotkeys|gestures|sap|dynamicoverlay|rss|libball|bargraph|clone|access_shm|mosaic|imem|osdmenu|puzzle|mediadirs|t140|ripple|motion|sharpen|grain|posterize|mirror|wall|scene|blendbench|psychedelic|alphamask|netsync|audioscrobbler|imem|motiondetect|export|smf|podcast|bluescreen|erase|record|speex_resampler|remoteosd|magnify|gradient|spdif|dtstofloat32" | tr \\\\n \ `
+VLC_MODULES=`find $(VLC_BUILD_DIR)/modules -name 'lib*_plugin.a'|grep -v -E "stats|access_bd|oldrc|real|hotkeys|gestures|sap|dynamicoverlay|rss|libball|bargraph|clone|access_shm|mosaic|imem|osdmenu|puzzle|mediadirs|t140|ripple|motion|sharpen|grain|posterize|mirror|wall|scene|blendbench|psychedelic|alphamask|netsync|audioscrobbler|imem|motiondetect|export|smf|podcast|bluescreen|erase|record|speex_resampler|remoteosd|magnify|gradient|spdif|dtstofloat32|logger" | tr \\\\n \ `
 
 $(LIBVLCJNI_H):
 	$(VERBOSE)if [ -z "$(VLC_BUILD_DIR)" ]; then echo "VLC_BUILD_DIR not defined" ; exit 1; fi
diff --git a/vlc-android/jni/libvlcjni.c b/vlc-android/jni/libvlcjni.c
index 882f609..ab0d27b 100644
--- a/vlc-android/jni/libvlcjni.c
+++ b/vlc-android/jni/libvlcjni.c
@@ -222,6 +222,27 @@ void Java_org_videolan_vlc_LibVLC_detachSurface(JNIEnv *env, jobject thiz) {
     pthread_mutex_unlock(&vout_android_lock);
 }
 
+static void debug_log(void *data, int level, const char *fmt, va_list ap)
+{
+    (void)data;
+
+    static const uint8_t priority[5] = {
+        [LIBVLC_DEBUG]   = ANDROID_LOG_DEBUG,
+        [1 /* ??? */]    = ANDROID_LOG_DEBUG,
+        [LIBVLC_NOTICE]  = ANDROID_LOG_INFO,
+        [LIBVLC_WARNING] = ANDROID_LOG_WARN,
+        [LIBVLC_ERROR]   = ANDROID_LOG_ERROR,
+    };
+
+    int prio = ANDROID_LOG_DEBUG;
+    if (level >= LIBVLC_DEBUG && level <= LIBVLC_ERROR)
+        prio = priority[level];
+
+    __android_log_vprint(prio, "VLC", fmt, ap);
+}
+
+static libvlc_log_subscriber_t debug_subscriber;
+
 void Java_org_videolan_vlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
 {
     //only use OpenSLES if java side says we can
@@ -229,6 +250,8 @@ void Java_org_videolan_vlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
     jmethodID methodId = (*env)->GetMethodID(env, cls, "getAout", "()I");
     bool use_opensles = (*env)->CallIntMethod(env, thiz, methodId) == AOUT_OPENSLES;
 
+    libvlc_log_subscribe(&debug_subscriber, debug_log, NULL);
+
     /* Don't add any invalid options, otherwise it causes LibVLC to crash */
     const char *argv[] = {
         "-I", "dummy",
@@ -238,8 +261,6 @@ void Java_org_videolan_vlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
         "--no-stats",
         "--no-plugins-cache",
         "--no-drop-late-frames",
-        "--control", "logger",
-        "--logmode", "android",
         "--ffmpeg-fast",
         use_opensles ? "--aout=opensles" : "--aout=android_audiotrack"
     };
@@ -284,6 +305,7 @@ void Java_org_videolan_vlc_LibVLC_nativeDestroy(JNIEnv *env, jobject thiz)
 
     libvlc_instance_t *instance = (libvlc_instance_t*) libVlcInstance;
     libvlc_release(instance);
+    libvlc_log_unsubscribe(&debug_subscriber);
 
     (*env)->SetIntField(env, thiz, field, 0);
 }



More information about the Android mailing list