diff options
Diffstat (limited to 'media/libcubeb/src/cubeb_log.h')
-rw-r--r-- | media/libcubeb/src/cubeb_log.h | 39 |
1 files changed, 32 insertions, 7 deletions
diff --git a/media/libcubeb/src/cubeb_log.h b/media/libcubeb/src/cubeb_log.h index bca98c96f..aee31805e 100644 --- a/media/libcubeb/src/cubeb_log.h +++ b/media/libcubeb/src/cubeb_log.h @@ -8,18 +8,34 @@ #ifndef CUBEB_LOG #define CUBEB_LOG +#include "cubeb/cubeb.h" + #ifdef __cplusplus extern "C" { #endif #if defined(__GNUC__) || defined(__clang__) #define PRINTF_FORMAT(fmt, args) __attribute__((format(printf, fmt, args))) +#if defined(__FILE_NAME__) +#define __FILENAME__ __FILE_NAME__ +#else +#define __FILENAME__ \ + (__builtin_strrchr(__FILE__, '/') ? __builtin_strrchr(__FILE__, '/') + 1 \ + : __FILE__) +#endif #else #define PRINTF_FORMAT(fmt, args) +#include <string.h> +#define __FILENAME__ \ + (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__) #endif -extern cubeb_log_level g_log_level; -extern cubeb_log_callback g_log_callback PRINTF_FORMAT(1, 2); +extern cubeb_log_level g_cubeb_log_level; +extern cubeb_log_callback g_cubeb_log_callback PRINTF_FORMAT(1, 2); +void +cubeb_async_log(const char * fmt, ...); +void +cubeb_async_log_reset_threads(); #ifdef __cplusplus } @@ -28,10 +44,19 @@ extern cubeb_log_callback g_log_callback PRINTF_FORMAT(1, 2); #define LOGV(msg, ...) LOG_INTERNAL(CUBEB_LOG_VERBOSE, msg, ##__VA_ARGS__) #define LOG(msg, ...) LOG_INTERNAL(CUBEB_LOG_NORMAL, msg, ##__VA_ARGS__) -#define LOG_INTERNAL(level, fmt, ...) do { \ - if (g_log_callback && level <= g_log_level) { \ - g_log_callback("%s:%d: " fmt "\n", __FILE__, __LINE__, ##__VA_ARGS__); \ - } \ - } while(0) +#define LOG_INTERNAL(level, fmt, ...) \ + do { \ + if (g_cubeb_log_callback && level <= g_cubeb_log_level) { \ + g_cubeb_log_callback("%s:%d: " fmt "\n", __FILENAME__, __LINE__, \ + ##__VA_ARGS__); \ + } \ + } while (0) + +/* Asynchronous verbose logging, to log in real-time callbacks. */ +/* Should not be used on android due to the use of global/static variables. */ +#define ALOGV(fmt, ...) \ + do { \ + cubeb_async_log(fmt, ##__VA_ARGS__); \ + } while (0) #endif // CUBEB_LOG |