diff options
-rw-r--r-- | CMakeLists.txt | 7 | ||||
-rw-r--r-- | OpenAL32/Include/alMain.h | 11 |
2 files changed, 18 insertions, 0 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index 3e608146..690ec37a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -213,6 +213,13 @@ ELSE() ENDIF() UNSET(OLD_REQUIRED_LIBRARIES) +# Include liblog for Android logging +CHECK_LIBRARY_EXISTS(log __android_log_print "" HAVE_LIBLOG) +IF(HAVE_LIBLOG) + SET(EXTRA_LIBS log ${EXTRA_LIBS}) + SET(CMAKE_REQUIRED_LIBRARIES ${CMAKE_REQUIRED_LIBRARIES} log) +ENDIF() + # Check if we have C99 variable length arrays CHECK_C_SOURCE_COMPILES( "int main(int argc, char *argv[]) diff --git a/OpenAL32/Include/alMain.h b/OpenAL32/Include/alMain.h index 1fb1dcf5..988c7d31 100644 --- a/OpenAL32/Include/alMain.h +++ b/OpenAL32/Include/alMain.h @@ -914,6 +914,13 @@ void al_print(const char *type, const char *func, const char *fmt, ...) DECL_FOR #define AL_PRINT(T, ...) al_print((T), __FUNCTION__, __VA_ARGS__) #endif +#ifdef __ANDROID__ +#include <android/log.h> +#define LOG_ANDROID(T, MSG, ...) __android_log_print(T, "openal", "AL lib: %s: "MSG, __FUNCTION__ , ## __VA_ARGS__) +#else +#define LOG_ANDROID(T, MSG, ...) ((void)0) +#endif + enum LogLevel { NoLog, LogError, @@ -926,21 +933,25 @@ extern enum LogLevel LogLevel; #define TRACEREF(...) do { \ if(LogLevel >= LogRef) \ AL_PRINT("(--)", __VA_ARGS__); \ + LOG_ANDROID(ANDROID_LOG_VERBOSE, __VA_ARGS__); \ } while(0) #define TRACE(...) do { \ if(LogLevel >= LogTrace) \ AL_PRINT("(II)", __VA_ARGS__); \ + LOG_ANDROID(ANDROID_LOG_DEBUG, __VA_ARGS__); \ } while(0) #define WARN(...) do { \ if(LogLevel >= LogWarning) \ AL_PRINT("(WW)", __VA_ARGS__); \ + LOG_ANDROID(ANDROID_LOG_WARN, __VA_ARGS__); \ } while(0) #define ERR(...) do { \ if(LogLevel >= LogError) \ AL_PRINT("(EE)", __VA_ARGS__); \ + LOG_ANDROID(ANDROID_LOG_ERROR, __VA_ARGS__); \ } while(0) |