[Android] [PATCH 3/3] remove libvlc log callbacks
Thomas Guillem
thomas at gllm.fr
Mon Feb 9 19:31:57 CET 2015
There is now an android logger module in vlc.
---
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 27d4e06..18903bd 100644
--- a/libvlc/jni/libvlcjni.c
+++ b/libvlc/jni/libvlcjni.c
@@ -456,8 +456,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);
}
@@ -471,7 +469,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 e7284ea..88b087f 100644
--- a/libvlc/src/org/videolan/libvlc/LibVLC.java
+++ b/libvlc/src/org/videolan/libvlc/LibVLC.java
@@ -69,10 +69,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;
-
private AudioOutput mAout;
/** Keep screen bright */
@@ -492,7 +488,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());
@@ -589,23 +584,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);
--
2.1.3
More information about the Android
mailing list