libs: display: redirect logging at initialize

Redirect libva's logs to GStreamer logging mechanism. This is
particularly useful when VA is initialized, because it always logs
out the drivers details.

In order to achieve this a new helper function was added as a wrapper
for the vaInitialize() function.

https://bugzilla.gnome.org/show_bug.cgi?id=777115
This commit is contained in:
Víctor Manuel Jáquez Leal 2017-01-11 16:04:24 +01:00
parent bca2b1680b
commit 1e0b3c2f74
4 changed files with 40 additions and 7 deletions

View file

@ -900,8 +900,6 @@ gst_vaapi_display_create_unlocked (GstVaapiDisplay * display,
GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display); GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display);
const GstVaapiDisplayClass *const klass = const GstVaapiDisplayClass *const klass =
GST_VAAPI_DISPLAY_GET_CLASS (display); GST_VAAPI_DISPLAY_GET_CLASS (display);
gint major_version, minor_version;
VAStatus status;
GstVaapiDisplayInfo info; GstVaapiDisplayInfo info;
const GstVaapiDisplayInfo *cached_info = NULL; const GstVaapiDisplayInfo *cached_info = NULL;
@ -947,10 +945,8 @@ gst_vaapi_display_create_unlocked (GstVaapiDisplay * display,
} }
if (!priv->parent) { if (!priv->parent) {
status = vaInitialize (priv->display, &major_version, &minor_version); if (!vaapi_initialize (priv->display))
if (!vaapi_check_status (status, "vaInitialize()"))
return FALSE; return FALSE;
GST_DEBUG ("VA-API version %d.%d", major_version, minor_version);
} }
if (!cached_info) { if (!cached_info) {

View file

@ -63,13 +63,12 @@ supports_vaapi (int fd)
{ {
gboolean ret; gboolean ret;
VADisplay va_dpy; VADisplay va_dpy;
int major, minor;
va_dpy = vaGetDisplayDRM (fd); va_dpy = vaGetDisplayDRM (fd);
if (!va_dpy) if (!va_dpy)
return FALSE; return FALSE;
ret = (vaInitialize (va_dpy, &major, &minor) == VA_STATUS_SUCCESS); ret = vaapi_initialize (va_dpy);
vaTerminate (va_dpy); vaTerminate (va_dpy);
return ret; return ret;
} }

View file

@ -45,6 +45,39 @@
#define STRCASEP(p, x) STRCASE(CONCAT(p, x)) #define STRCASEP(p, x) STRCASE(CONCAT(p, x))
#define STRCASE(x) case x: return STRINGIFY(x) #define STRCASE(x) case x: return STRINGIFY(x)
#if VA_CHECK_VERSION (0,39,4)
static void
gst_vaapi_log (const char *message)
{
gchar *msg;
msg = g_strdup (message);
if (!msg)
return;
g_strchomp (msg);
GST_INFO ("%s", msg);
g_free (msg);
}
#endif
gboolean
vaapi_initialize (VADisplay dpy)
{
gint major_version, minor_version;
VAStatus status;
#if VA_CHECK_VERSION (0,39,4)
vaSetInfoCallback (gst_vaapi_log);
#endif
status = vaInitialize (dpy, &major_version, &minor_version);
if (!vaapi_check_status (status, "vaInitialize()"))
return FALSE;
GST_INFO ("VA-API version %d.%d", major_version, minor_version);
return TRUE;
}
/* Check VA status for success or print out an error */ /* Check VA status for success or print out an error */
gboolean gboolean
vaapi_check_status (VAStatus status, const gchar * msg) vaapi_check_status (VAStatus status, const gchar * msg)

View file

@ -30,6 +30,11 @@
#include <glib.h> #include <glib.h>
#include <va/va.h> #include <va/va.h>
/** calls vaInitialize() redirecting the logging mechanism */
G_GNUC_INTERNAL
gboolean
vaapi_initialize (VADisplay dpy);
/** Check VA status for success or print out an error */ /** Check VA status for success or print out an error */
G_GNUC_INTERNAL G_GNUC_INTERNAL
gboolean gboolean