]> git.sesse.net Git - vlc/blobdiff - src/misc/messages.c
decoder: remove unnecessary special case
[vlc] / src / misc / messages.c
index 77a5ec9f4f4961819c52d86e29bf753fa4681cb2..e22e4fe742fb4587c6c394eb561b150ea8a130d4 100644 (file)
 #include <vlc_modules.h>
 #include "../libvlc.h"
 
-#ifdef __ANDROID__
-#include <android/log.h>
-#endif
-
 struct vlc_logger_t
 {
     VLC_COMMON_MEMBERS
@@ -88,6 +84,7 @@ static void Win32DebugOutputMsg (void *, int , const vlc_log_t *,
  * to vlc_Log().
  */
 void vlc_vaLog (vlc_object_t *obj, int type, const char *module,
+                const char *file, unsigned line, const char *func,
                 const char *format, va_list args)
 {
     if (obj != NULL && obj->i_flags & OBJECT_FLAGS_QUIET)
@@ -115,6 +112,9 @@ void vlc_vaLog (vlc_object_t *obj, int type, const char *module,
     msg.psz_object_type = (obj != NULL) ? obj->psz_object_type : "generic";
     msg.psz_module = module;
     msg.psz_header = NULL;
+    msg.file = file;
+    msg.line = line;
+    msg.func = func;
 
     for (vlc_object_t *o = obj; o != NULL; o = o->p_parent)
         if (o->psz_header != NULL)
@@ -142,15 +142,19 @@ void vlc_vaLog (vlc_object_t *obj, int type, const char *module,
  * \param type VLC_MSG_* message type (info, error, warning or debug)
  * \param module name of module from which the message come
  *               (normally MODULE_STRING)
+ * \param file source module file name (normally __FILE__) or NULL
+ * \param line function call source line number (normally __LINE__) or 0
+ * \param func calling function name (normally __func__) or NULL
  * \param format printf-like message format
  */
 void vlc_Log(vlc_object_t *obj, int type, const char *module,
+             const char *file, unsigned line, const char *func,
              const char *format, ... )
 {
     va_list ap;
 
     va_start(ap, format);
-    vlc_vaLog(obj, type, module, format, ap);
+    vlc_vaLog(obj, type, module, file, line, func, format, ap);
     va_end(ap);
 }
 
@@ -197,43 +201,6 @@ static void Win32DebugOutputMsg (void* d, int type, const vlc_log_t *p_item,
 }
 #endif
 
-#ifdef __ANDROID__
-static void AndroidPrintMsg (void *d, int type, const vlc_log_t *p_item,
-                             const char *format, va_list ap)
-{
-    int verbose = (intptr_t)d;
-    int prio;
-
-    if (verbose < 0 || verbose < (type - VLC_MSG_ERR))
-        return;
-
-    int canc = vlc_savecancel ();
-
-    char *format2;
-    if (asprintf (&format2, "[%0*"PRIxPTR"] %s %s: %s",
-                  ptr_width, p_item->i_object_id, p_item->psz_module,
-                  p_item->psz_object_type, format) < 0)
-        return;
-    switch (type) {
-        case VLC_MSG_INFO:
-            prio = ANDROID_LOG_INFO;
-            break;
-        case VLC_MSG_ERR:
-            prio = ANDROID_LOG_ERROR;
-            break;
-        case VLC_MSG_WARN:
-            prio = ANDROID_LOG_WARN;
-            break;
-        default:
-        case VLC_MSG_DBG:
-            prio = ANDROID_LOG_DEBUG;
-    }
-    __android_log_vprint (prio, "VLC", format2, ap);
-    free (format2);
-    vlc_restorecancel (canc);
-}
-#endif
-
 typedef struct vlc_log_early_t
 {
     struct vlc_log_early_t *next;
@@ -265,6 +232,9 @@ static void vlc_vaLogEarly(void *d, int type, const vlc_log_t *item,
     log->meta.psz_object_type = item->psz_object_type;
     log->meta.psz_module = item->psz_module; /* Ditto. */
     log->meta.psz_header = item->psz_header ? strdup(item->psz_header) : NULL;
+    log->meta.file = item->file;
+    log->meta.line = item->line;
+    log->meta.func = item->func;
 
     int canc = vlc_savecancel(); /* XXX: needed for vasprintf() ? */
     if (vasprintf(&log->msg, format, ap) == -1)
@@ -392,11 +362,7 @@ int vlc_LogInit(libvlc_int_t *vlc)
     module_t *module = vlc_module_load(logger, "logger", NULL, false,
                                        vlc_logger_load, logger, &cb, &sys);
     if (module == NULL)
-#ifdef __ANDROID__
-        cb = AndroidPrintMsg, sys = NULL;
-#else
         cb = vlc_vaLogDiscard;
-#endif
 
     vlc_rwlock_wrlock(&logger->lock);
     if (logger->log == vlc_vaLogEarly)