Commit 9a2debd6 authored by Thomas Guillem's avatar Thomas Guillem

android/thread: rework THREAD_ASSERT

Don't depend on android liblog. Print the error message on stderr. This message
can be lost, but the most important part is the full backtrace produced by the
failing assert.
parent d3b4d99e
......@@ -42,8 +42,6 @@
#include <pthread.h>
#include <sched.h>
#include <android/log.h>
#if !defined(HAVE_PTHREAD_CONDATTR_SETCLOCK) && !defined(HAVE_PTHREAD_COND_TIMEDWAIT_MONOTONIC_NP)
#error no pthread monotonic clock support
#endif
......@@ -52,8 +50,8 @@
#ifndef NDEBUG
static void
vlc_thread_fatal (const char *action, int error,
const char *function, const char *file, unsigned line)
vlc_thread_fatal_print (const char *action, int error,
const char *function, const char *file, unsigned line)
{
char buf[1000];
const char *msg;
......@@ -71,17 +69,18 @@ vlc_thread_fatal (const char *action, int error,
break;
}
__android_log_print(ANDROID_LOG_ERROR, "vlc",
"LibVLC fatal error %s (%d) in thread %lu "
"at %s:%u in %s\n Error message: %s\n",
action, error, vlc_thread_id (), file, line, function, msg);
abort ();
fprintf(stderr, "LibVLC fatal error %s (%d) in thread %lu "
"at %s:%u in %s\n Error message: %s\n",
action, error, vlc_thread_id (), file, line, function, msg);
fflush (stderr);
}
# define VLC_THREAD_ASSERT( action ) \
if (unlikely(val)) \
vlc_thread_fatal (action, val, __func__, __FILE__, __LINE__)
# define VLC_THREAD_ASSERT( action ) do { \
if (unlikely(val)) { \
vlc_thread_fatal_print (action, val, __func__, __FILE__, __LINE__); \
assert (!action); \
} \
} while(0)
#else
# define VLC_THREAD_ASSERT( action ) ((void)val)
#endif
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment