2 changed files with 99 additions and 2 deletions
@ -0,0 +1,97 @@ |
|||
From 5e1faeb801e3eec6e2876021202289a5a149e2a1 Mon Sep 17 00:00:00 2001 |
|||
From: Jean-Baptiste Kempf <jb@videolan.org> |
|||
Date: Sun, 31 Jul 2011 00:20:40 +0200 |
|||
Subject: [PATCH 3/7] Push messages to Android stack |
|||
|
|||
Signed-off-by: Jean-Baptiste Kempf <jb@videolan.org> |
|||
---
|
|||
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 e61f372..90de262 100644
|
|||
--- a/configure.ac
|
|||
+++ b/configure.ac
|
|||
@@ -471,6 +471,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 61080c0..f92d4c0 100644
|
|||
--- a/src/misc/messages.c
|
|||
+++ b/src/misc/messages.c
|
|||
@@ -224,10 +224,17 @@ void vlc_vaLog (vlc_object_t *obj, int type, const char *module,
|
|||
va_list ap; |
|||
|
|||
va_copy (ap, args); |
|||
+#ifdef __ANDROID__
|
|||
+#include <android/log.h>
|
|||
+ 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); |
|||
|
|||
vlc_rwlock_rdlock (&msg_lock); |
|||
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 <android/log.h>
|
|||
+# 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 |
|||
|
|||
Loading…
Reference in new issue