continue;
if (strcmp(token, env) == 0) {
- if (env_value)
+ if (env_value) {
strncpy(env_value,value, 1024);
+ env_value[1023] = '\0';
+ }
fclose(fp);
/* no setting in config file, use env setting */
value = getenv(env);
if (value) {
- if (env_value)
+ if (env_value) {
strncpy(env_value, value, 1024);
+ env_value[1023] = '\0';
+ }
return 0;
}
return pDisplayContext && (pDisplayContext->vadpy_magic == VA_DISPLAY_MAGIC) && pDisplayContext->vaIsValid(pDisplayContext);
}
+static void default_log_error(const char *buffer)
+{
+# ifdef ANDROID_ALOG
+ ALOGE("%s", buffer);
+# elif ANDROID_LOG
+ LOGE("%s", buffer);
+# else
+ fprintf(stderr, "libva error: %s", buffer);
+# endif
+}
+
+static void default_log_info(const char *buffer)
+{
+# ifdef ANDROID_ALOG
+ ALOGI("%s", buffer);
+# elif ANDROID_LOG
+ LOGI("%s", buffer);
+# else
+ fprintf(stderr, "libva info: %s", buffer);
+# endif
+}
+
+static vaMessageCallback va_log_error = default_log_error;
+static vaMessageCallback va_log_info = default_log_info;
+
+/**
+ * Set the callback for error messages, or NULL for no logging.
+ * Returns the previous one, or NULL if it was disabled.
+ */
+vaMessageCallback vaSetErrorCallback(vaMessageCallback callback)
+{
+ vaMessageCallback old_callback = va_log_error;
+ va_log_error = callback;
+ return old_callback;
+}
+
+/**
+ * Set the callback for info messages, or NULL for no logging.
+ * Returns the previous one, or NULL if it was disabled.
+ */
+vaMessageCallback vaSetInfoCallback(vaMessageCallback callback)
+{
+ vaMessageCallback old_callback = va_log_info;
+ va_log_info = callback;
+ return old_callback;
+}
+
void va_errorMessage(const char *msg, ...)
{
char buf[512], *dynbuf;
va_list args;
int n, len;
+ if (va_log_error == NULL)
+ return;
+
va_start(args, msg);
len = vsnprintf(buf, sizeof(buf), msg, args);
va_end(args);
va_list args;
int n, len;
+ if (va_log_info == NULL)
+ return;
+
va_start(args, msg);
len = vsnprintf(buf, sizeof(buf), msg, args);
va_end(args);