diff options
Diffstat (limited to 'va')
-rwxr-xr-x | va/Android.mk | 12 | ||||
-rw-r--r-- | va/sysdeps.h | 24 | ||||
-rw-r--r-- | va/va.c | 38 |
3 files changed, 70 insertions, 4 deletions
diff --git a/va/Android.mk b/va/Android.mk index 6777f6d..a7d6e19 100755 --- a/va/Android.mk +++ b/va/Android.mk @@ -27,6 +27,11 @@ LOCAL_PATH:= $(call my-dir) LIBVA_DRIVERS_PATH = /system/lib +# Version set to Android Jelly Bean +ALOG_VERSION_REQ := 4.1 +ALOG_VERSION := $(filter $(ALOG_VERSION_REQ),$(firstword $(sort $(PLATFORM_VERSION) \ + $(ALOG_VERSION_REQ)))) + include $(CLEAR_VARS) #LIBVA_MINOR_VERSION := 31 @@ -41,6 +46,13 @@ LOCAL_CFLAGS += \ -DANDROID \ -DVA_DRIVERS_PATH="\"$(LIBVA_DRIVERS_PATH)\"" +# Android Jelly Bean defined ALOGx, older versions use LOGx +ifeq ($(ALOG_VERSION), $(ALOG_VERSION_REQ)) +LOCAL_CFLAGS += -DANDROID_ALOG +else +LOCAL_CFLAGS += -DANDROID_LOG +endif + LOCAL_C_INCLUDES += \ $(TARGET_OUT_HEADERS)/libva \ $(LOCAL_PATH)/x11 \ diff --git a/va/sysdeps.h b/va/sysdeps.h index 77db28a..730735b 100644 --- a/va/sysdeps.h +++ b/va/sysdeps.h @@ -40,6 +40,30 @@ # define Bool int # define True 1 # define False 0 + +/* Android logging utilities */ +# define LOG_TAG "lib-va" +# include <utils/Log.h> + +# ifdef ANDROID_ALOG +# define va_log_error(buffer) do { ALOGE("%s", buffer); } while (0) +# define va_log_info(buffer) do { ALOGI("%s", buffer); } while (0) +# elif ANDROID_LOG +# define va_log_error(buffer) do { LOGE("%s", buffer); } while (0) +# define va_log_info(buffer) do { LOGI("%s", buffer); } while (0) +# endif +#endif + +#ifndef va_log_error +#define va_log_error(buffer) do { \ + fprintf(stderr, "libva error: %s", buffer); \ + } while (0) +#endif + +#ifndef va_log_info +#define va_log_info(buffer) do { \ + fprintf(stderr, "libva info: %s", buffer); \ + } while (0) #endif #if defined __GNUC__ && defined HAVE_GNUC_VISIBILITY_ATTRIBUTE @@ -103,22 +103,52 @@ int vaDisplayIsValid(VADisplay dpy) void va_errorMessage(const char *msg, ...) { + char buf[512], *dynbuf; va_list args; + int n, len; - fprintf(stderr, "libva error: "); va_start(args, msg); - vfprintf(stderr, msg, args); + len = vsnprintf(buf, sizeof(buf), msg, args); va_end(args); + + if (len >= (int)sizeof(buf)) { + dynbuf = malloc(len + 1); + if (!dynbuf) + return; + va_start(args, msg); + n = vsnprintf(dynbuf, len + 1, msg, args); + va_end(args); + if (n == len) + va_log_error(dynbuf); + free(dynbuf); + } + else if (len > 0) + va_log_error(buf); } void va_infoMessage(const char *msg, ...) { + char buf[512], *dynbuf; va_list args; + int n, len; - fprintf(stderr, "libva: "); va_start(args, msg); - vfprintf(stderr, msg, args); + len = vsnprintf(buf, sizeof(buf), msg, args); va_end(args); + + if (len >= (int)sizeof(buf)) { + dynbuf = malloc(len + 1); + if (!dynbuf) + return; + va_start(args, msg); + n = vsnprintf(dynbuf, len + 1, msg, args); + va_end(args); + if (n == len) + va_log_info(dynbuf); + free(dynbuf); + } + else if (len > 0) + va_log_info(buf); } static bool va_checkVtable(void *ptr, char *function) |