[Android] remove libvlc log callbacks

Thomas Guillem git at videolan.org
Tue Feb 10 13:36:02 CET 2015


vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Mon Feb  9 11:12:37 2015 +0100| [957cfb85431bdab4247d13398c3546e2d3e03e7f] | committer: Thomas Guillem

remove libvlc log callbacks

There is now an android logger module in vlc.

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=957cfb85431bdab4247d13398c3546e2d3e03e7f
---

 libvlc/jni/libvlcjni-util.c                |  113 ----------------------------
 libvlc/jni/libvlcjni.c                     |    3 -
 libvlc/jni/utils.h                         |    2 -
 libvlc/src/org/videolan/libvlc/LibVLC.java |   22 ------
 4 files changed, 140 deletions(-)

diff --git a/libvlc/jni/libvlcjni-util.c b/libvlc/jni/libvlcjni-util.c
index 205d59d..8e50962 100644
--- a/libvlc/jni/libvlcjni-util.c
+++ b/libvlc/jni/libvlcjni-util.c
@@ -31,11 +31,6 @@
 #define LOG_TAG "VLC/JNI/Util"
 #include "log.h"
 
-static jobject debugBufferInstance = NULL;
-
-// FIXME: use atomics
-static bool buffer_logging;
-
 #define THREAD_NAME "libvlcjni-util"
 extern int jni_attach_thread(JNIEnv **env, const char *thread_name);
 extern void jni_detach_thread();
@@ -148,114 +143,6 @@ jobject getEventHandlerReference(JNIEnv *env, jobject thiz, jobject eventHandler
     return (*env)->NewGlobalRef(env, eventHandler);
 }
 
-static void debug_buffer_log(void *data, int level, const char *fmt, va_list ap)
-{
-    bool isAttached = false;
-    JNIEnv *env = NULL;
-
-    if (jni_get_env(&env) < 0) {
-        if (jni_attach_thread(&env, THREAD_NAME) < 0)
-            return;
-        isAttached = true;
-    }
-
-    /* Prepare message string */
-    char* psz_fmt_newline = malloc(strlen(fmt) + 2);
-    if(!psz_fmt_newline)
-        return;
-    strcpy(psz_fmt_newline, fmt);
-    strcat(psz_fmt_newline, "\n");
-    char* psz_msg = NULL;
-    int res = vasprintf(&psz_msg, psz_fmt_newline, ap);
-    free(psz_fmt_newline);
-    if(res < 0)
-        return;
-
-    jobject buffer = debugBufferInstance;
-    jclass buffer_class = (*env)->FindClass(env, "java/lang/StringBuffer");
-    jmethodID bufferAppendID = (*env)->GetMethodID(env, buffer_class, "append", "(Ljava/lang/String;)Ljava/lang/StringBuffer;");
-
-    jstring message = (*env)->NewStringUTF(env, psz_msg);
-    (*env)->CallObjectMethod(env, buffer, bufferAppendID, message);
-    (*env)->DeleteLocalRef(env, message);
-    free(psz_msg);
-
-    if (isAttached)
-        jni_detach_thread();
-}
-
-void debug_log(void *data, int level, const libvlc_log_t *ctx, const char *fmt, va_list ap)
-{
-    bool *verbose = 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];
-
-    /* Quit if we are not doing anything */
-    if(!buffer_logging && (!(*verbose) && prio < ANDROID_LOG_ERROR))
-        return;
-
-    /* Add emitting module & type */
-    char* fmt2 = NULL;
-    if(asprintf(&fmt2, "%s %s: %s", ctx->psz_module, ctx->psz_object_type, fmt) < 0)
-        return;
-
-    if (buffer_logging) {
-        va_list aq;
-        va_copy(aq, ap);
-        debug_buffer_log(data, level, fmt2, aq);
-        va_end(aq);
-    }
-
-    __android_log_vprint(prio, "VLC", fmt2, ap);
-    free(fmt2);
-}
-
-void Java_org_videolan_libvlc_LibVLC_startDebugBuffer(JNIEnv *env, jobject thiz)
-{
-    jclass libVLC_class = (*env)->FindClass(env, "org/videolan/libvlc/LibVLC");
-    jmethodID getInstance = (*env)->GetStaticMethodID(env, libVLC_class, "getInstance", "()Lorg/videolan/libvlc/LibVLC;");
-    jobject libvlcj = (*env)->CallStaticObjectMethod(env, libVLC_class, getInstance);
-
-    jfieldID bufferID = (*env)->GetFieldID(env, libVLC_class, "mDebugLogBuffer", "Ljava/lang/StringBuffer;");
-    jobject buffer = (*env)->GetObjectField(env, libvlcj, bufferID);
-
-    debugBufferInstance = (*env)->NewGlobalRef(env, buffer);
-    (*env)->DeleteLocalRef(env, buffer);
-
-    jfieldID buffer_flag = (*env)->GetFieldID(env, libVLC_class, "mIsBufferingLog", "Z");
-    (*env)->SetBooleanField(env, libvlcj, buffer_flag, JNI_TRUE);
-
-    (*env)->DeleteLocalRef(env, libVLC_class);
-    (*env)->DeleteLocalRef(env, libvlcj);
-    buffer_logging = true;
-}
-
-void Java_org_videolan_libvlc_LibVLC_stopDebugBuffer(JNIEnv *env, jobject thiz)
-{
-    buffer_logging = false;
-    jclass libVLC_class = (*env)->FindClass(env, "org/videolan/libvlc/LibVLC");
-    jmethodID getInstance = (*env)->GetStaticMethodID(env, libVLC_class, "getInstance", "()Lorg/videolan/libvlc/LibVLC;");
-    jobject libvlcj = (*env)->CallStaticObjectMethod(env, libVLC_class, getInstance);
-
-    (*env)->DeleteGlobalRef(env, debugBufferInstance);
-
-    jfieldID buffer_flag = (*env)->GetFieldID(env, libVLC_class, "mIsBufferingLog", "Z");
-    (*env)->SetBooleanField(env, libvlcj, buffer_flag, JNI_FALSE);
-
-    (*env)->DeleteLocalRef(env, libVLC_class);
-    (*env)->DeleteLocalRef(env, libvlcj);
-}
-
 jstring Java_org_videolan_libvlc_LibVLC_nativeToURI(JNIEnv *env, jobject thiz, jstring path)
 {
     jboolean isCopy;
diff --git a/libvlc/jni/libvlcjni.c b/libvlc/jni/libvlcjni.c
index 96df260..965a0f9 100644
--- a/libvlc/jni/libvlcjni.c
+++ b/libvlc/jni/libvlcjni.c
@@ -458,8 +458,6 @@ void Java_org_videolan_libvlc_LibVLC_nativeInit(JNIEnv *env, jobject thiz)
 
     LOGI("LibVLC initialized: %p", instance);
 
-    libvlc_log_set(instance, debug_log, &verbosity);
-
     init_native_crash_handler(env, thiz);
 }
 
@@ -473,7 +471,6 @@ void Java_org_videolan_libvlc_LibVLC_nativeDestroy(JNIEnv *env, jobject thiz)
         return; // Already destroyed
 
     libvlc_instance_t *instance = (libvlc_instance_t*)(intptr_t) libVlcInstance;
-    libvlc_log_unset(instance);
     libvlc_release(instance);
 
     setLong(env, thiz, "mLibVlcInstance", 0);
diff --git a/libvlc/jni/utils.h b/libvlc/jni/utils.h
index 30df7ca..3c28e88 100644
--- a/libvlc/jni/utils.h
+++ b/libvlc/jni/utils.h
@@ -74,6 +74,4 @@ void arrayListStringAdd(JNIEnv *env, jclass class, jmethodID methodID, jobject a
 
 jobject getEventHandlerReference(JNIEnv *env, jobject thiz, jobject eventHandler);
 
-void debug_log(void *data, int level, const libvlc_log_t *ctx, const char *fmt, va_list ap);
-
 #endif // LIBVLCJNI_UTILS_H
diff --git a/libvlc/src/org/videolan/libvlc/LibVLC.java b/libvlc/src/org/videolan/libvlc/LibVLC.java
index 9860436..b736d7b 100644
--- a/libvlc/src/org/videolan/libvlc/LibVLC.java
+++ b/libvlc/src/org/videolan/libvlc/LibVLC.java
@@ -68,10 +68,6 @@ public class LibVLC {
     /** libvlc_media_player pointer */
     private long mInternalMediaPlayerInstance = 0; // Read-only, reserved for JNI
 
-    /** Buffer for VLC messages */
-    private StringBuffer mDebugLogBuffer;
-    private boolean mIsBufferingLog = false;
-
     /** Keep screen bright */
     //private WakeLock mWakeLock;
 
@@ -488,7 +484,6 @@ public class LibVLC {
      */
     public void init(Context context) throws LibVlcException {
         Log.v(TAG, "Initializing LibVLC");
-        mDebugLogBuffer = new StringBuffer();
         if (!mIsInitialized) {
             if(!LibVlcUtil.hasCompatibleCPU(context)) {
                 Log.e(TAG, LibVlcUtil.getErrorMsg());
@@ -550,23 +545,6 @@ public class LibVLC {
     private native void nativeDestroy();
 
     /**
-     * Start buffering to the mDebugLogBuffer.
-     */
-    public native void startDebugBuffer();
-    public native void stopDebugBuffer();
-    public String getBufferContent() {
-        return mDebugLogBuffer.toString();
-    }
-
-    public void clearBuffer() {
-        mDebugLogBuffer.setLength(0);
-    }
-
-    public boolean isDebugBuffering() {
-        return mIsBufferingLog;
-    }
-
-    /**
      * Play an mrl
      */
     public native void playMRL(String mrl, String[] mediaOptions);



More information about the Android mailing list