From 054afb010cefa90f3ad8d50c23959be7375475b8 Mon Sep 17 00:00:00 2001 From: Jean-Baptiste Kempf Date: Sun, 31 Jul 2011 00:20:40 +0200 Subject: [PATCH 3/7] Push messages to Android stack Signed-off-by: Jean-Baptiste Kempf --- configure.ac | 1 + src/misc/messages.c | 7 +++++++ src/posix/thread.c | 16 ++++++++++++---- 3 files changed, 20 insertions(+), 4 deletions(-) diff --git a/configure.ac b/configure.ac index e739e75..d4a8d4e 100644 --- a/configure.ac +++ b/configure.ac @@ -445,6 +445,7 @@ fi if test "${HAVE_ANDROID}" = "1"; then AC_REPLACE_FUNCS([pthread_cancel]) + VLC_ADD_LIBS([libvlccore],[-llog]) fi dnl diff --git a/src/misc/messages.c b/src/misc/messages.c index 66bd62e..4308897 100644 --- a/src/misc/messages.c +++ b/src/misc/messages.c @@ -228,10 +228,17 @@ void vlc_vaLog (vlc_object_t *obj, int type, const char *module, va_list ap; va_copy (ap, args); +#ifdef __ANDROID__ +#include + android_LogPriority prioritytype[4] = {ANDROID_LOG_INFO, ANDROID_LOG_ERROR, + ANDROID_LOG_WARN, ANDROID_LOG_DEBUG }; + __android_log_vprint(prioritytype[type], "vlc", format, ap); +#else if (priv->b_color) PrintColorMsg (&priv->i_verbose, type, &msg, format, ap); else PrintMsg (&priv->i_verbose, type, &msg, format, ap); +#endif va_end (ap); #ifdef WIN32 diff --git a/src/posix/thread.c b/src/posix/thread.c index 9d9c771..d8a442b 100644 --- a/src/posix/thread.c +++ b/src/posix/thread.c @@ -136,6 +136,14 @@ static struct timespec mtime_to_ts (mtime_t date) return ts; } +#if defined(__ANDROID__) && !defined(NDEBUG) +# include +# define LOG_TAG "VLC/pthread" +# define FATAL(...) __android_log_print(ANDROID_LOG_ERROR,LOG_TAG,__VA_ARGS__) +#else +# define FATAL(...) fprintf(stderr, __VA_ARGS__) +#endif + /** * Print a backtrace to the standard error for debugging purpose. */ @@ -176,8 +184,8 @@ vlc_thread_fatal (const char *action, int error, const char *function, const char *file, unsigned line) { int canc = vlc_savecancel (); - fprintf (stderr, "LibVLC fatal error %s (%d) in thread %lu ", - action, error, vlc_threadid ()); + FATAL ("LibVLC fatal error %s (%d) in thread %lu ", + action, error, vlc_threadid ()); vlc_trace (function, file, line); /* Sometimes strerror_r() crashes too, so make sure we print an error @@ -185,7 +193,7 @@ vlc_thread_fatal (const char *action, int error, #ifdef __GLIBC__ /* Avoid the strerror_r() prototype brain damage in glibc */ errno = error; - fprintf (stderr, " Error message: %m\n"); + FATAL (" Error message: %m\n"); #else char buf[1000]; const char *msg; @@ -202,7 +210,7 @@ vlc_thread_fatal (const char *action, int error, msg = "unknown (invalid error number)"; break; } - fprintf (stderr, " Error message: %s\n", msg); + FATAL (" Error message: %s\n", msg); #endif fflush (stderr); -- 1.7.5.4