From 5142c2377300fe2bc3c430298fb5431aa3c8c0b8 Mon Sep 17 00:00:00 2001 From: Jaroslav Kysela Date: Sat, 2 Sep 2017 17:51:00 +0200 Subject: [PATCH] libva: vaapi - redirect the info/error callbacks to tvh's log --- src/libav.c | 47 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 47 insertions(+) diff --git a/src/libav.c b/src/libav.c index 24a08690a..ae9aa218e 100644 --- a/src/libav.c +++ b/src/libav.c @@ -1,5 +1,8 @@ #include "transcoding/transcode.h" #include "libav.h" +#if ENABLE_VAAPI +#include +#endif /** * @@ -219,6 +222,49 @@ libav_is_encoder(AVCodec *codec) #endif } +/** + * + */ +#if ENABLE_VAAPI +static void libav_va_log(int severity, const char *msg) +{ + char *s; + int l; + + if (msg == NULL || *msg == '\0') + return; + s = tvh_strdupa(msg); + l = strlen(s); + if (s[l-1] == '\n') + s[l-1] = '\0'; + tvhlog(severity, LS_VAAPI, "%s", s); +} + +static void libav_va_error_callback(const char *msg) +{ + libav_va_log(LOG_ERR, msg); +} + +static void libav_va_info_callback(const char *msg) +{ + libav_va_log(LOG_INFO, msg); +} +#endif + +/** + * + */ +static void +libav_vaapi_init(void) +{ +#if ENABLE_VAAPI +#ifdef VA_FOURCC_I010 + vaSetErrorCallback(libav_va_error_callback); + vaSetInfoCallback(libav_va_info_callback); +#endif +#endif +} + /** * */ @@ -235,6 +281,7 @@ libav_set_loglevel(void) void libav_init(void) { + libav_vaapi_init(); libav_set_loglevel(); av_log_set_callback(libav_log_callback); av_register_all(); -- 2.47.3