[Libva] [PATCH] android-log: enable logs according to Android version
Daniel Charles
daniel.charles at intel.com
Tue Jul 31 11:53:53 PDT 2012
Log functions available are now Android compatible and log statements
will show on user space android logging system.
Defined a LOG_TAG and make it available for all versions of Android.
Change-Id: I86f863a331fcdde96e0a114c7d3078a83b6566ad
Signed-off-by: Daniel Charles <daniel.charles at intel.com>
---
va/Android.mk | 13 +++++++++++--
va/sysdeps.h | 32 +++++++++++++++++++++++++-------
va/va.c | 11 +++++++----
3 files changed, 43 insertions(+), 13 deletions(-)
diff --git a/va/Android.mk b/va/Android.mk
index 4a9923e..97cac95 100755
--- a/va/Android.mk
+++ b/va/Android.mk
@@ -26,11 +26,13 @@
LOCAL_PATH:= $(call my-dir)
LIBVA_DRIVERS_PATH = /system/lib
+#Version set to Android Jelly Bean
+NEED_VERSION := 4.1
+USE_ALOG := $(filter $(NEED_VERSION),$(firstword $(sort $(PLATFORM_VERSION) \
+ $(NEED_VERSION))))
include $(CLEAR_VARS)
-#LIBVA_MINOR_VERSION := 31
-#LIBVA_MAJOR_VERSION := 0
LOCAL_SRC_FILES := \
va.c \
@@ -41,6 +43,13 @@ LOCAL_CFLAGS += \
-DANDROID \
-DVA_DRIVERS_PATH="\"$(LIBVA_DRIVERS_PATH)\""
+#Android Jelly Bean defined ALOGx, older versions use LOGx
+ifeq ($(USE_ALOG), $(NEED_VERSION))
+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 0752b17..5f1c6a9 100644
--- a/va/sysdeps.h
+++ b/va/sysdeps.h
@@ -22,11 +22,11 @@
* SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
-#ifndef SYSDEPS_H
-#define SYSDEPS_H
+#ifndef LIBVA_SYSDEPS_H_
+#define LIBVA_SYSDEPS_H_
#ifdef HAVE_CONFIG_H
-# include "config.h"
+#include "config.h"
#endif
#include <stdio.h>
@@ -36,9 +36,27 @@
#include <assert.h>
#ifdef ANDROID
-# define Bool int
-# define True 1
-# define False 0
+#define Bool int
+#define True 1
+#define False 0
+
+#define LOG_TAG "lib-va"
+#include <utils/Log.h>
+
+#ifdef ANDROID_ALOG
+#define VA_LOGE(buffer) ALOGE("%s", buffer);
+#define VA_LOGI(buffer) ALOGI("%s", buffer);
+#define VA_LOGV(buffer) ALOGV("%s", buffer);
+#elif ANDROID_LOG
+#define VA_LOGE(buffer) LOGE("%s", buffer);
+#define VA_LOGI(buffer) LOGI("%s", buffer);
+#define VA_LOGV(buffer) LOGV("%s", buffer);
#endif
-#endif /* SYSDEPS_H */
+#else
+
+#define VA_LOGE(buffer) fprintf(stderr, "libva error: %s", buffer);
+#define VA_LOGV(buffer) fprintf(stderr, "libva: %s", buffer);
+#define VA_LOGI(buffer) fprintf(stderr, "libva info: %s", buffer);
+#endif //ANDROID
+#endif//LIBVA_SYSDEPS_H_
diff --git a/va/va.c b/va/va.c
index 1bbe047..6adf821 100644
--- a/va/va.c
+++ b/va/va.c
@@ -105,21 +105,24 @@ int vaDisplayIsValid(VADisplay dpy)
void va_errorMessage(const char *msg, ...)
{
+ char buffer[1024];
va_list args;
- fprintf(stderr, "libva error: ");
va_start(args, msg);
- vfprintf(stderr, msg, args);
+ vsnprintf(buffer, 1024, msg, args);
+ VA_LOGE(buffer);
va_end(args);
+
}
void va_infoMessage(const char *msg, ...)
{
+ char buffer[1024];
va_list args;
- fprintf(stderr, "libva: ");
va_start(args, msg);
- vfprintf(stderr, msg, args);
+ vsnprintf(buffer, 1024, msg, args);
+ VA_LOGI(buffer);
va_end(args);
}
--
1.7.7.6
More information about the Libva
mailing list