From c0993182bd13afbf1362d1a7407effd01cbfcaa2 Mon Sep 17 00:00:00 2001 From: Gwenole Beauchesne Date: Tue, 20 May 2014 11:36:40 +0200 Subject: [PATCH] display: add utility function to query VA driver name. Add gst_vaapi_display_get_vendor_string() helper function to query the underlying VA driver name. The display object owns the resulting string, so it shall not be deallocated. That function is thread-safe. It could be used for debugging purposes, for instance. --- gst-libs/gst/vaapi/gstvaapidisplay.c | 41 +++++++++++++++++++++++ gst-libs/gst/vaapi/gstvaapidisplay.h | 3 ++ gst-libs/gst/vaapi/gstvaapidisplay_priv.h | 1 + 3 files changed, 45 insertions(+) diff --git a/gst-libs/gst/vaapi/gstvaapidisplay.c b/gst-libs/gst/vaapi/gstvaapidisplay.c index 776ab68b8f..64f02455d5 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplay.c +++ b/gst-libs/gst/vaapi/gstvaapidisplay.c @@ -854,6 +854,9 @@ gst_vaapi_display_destroy (GstVaapiDisplay * display) klass->close_display (display); } + g_free (priv->vendor_string); + priv->vendor_string = NULL; + gst_vaapi_display_replace_internal (&priv->parent, NULL); g_mutex_lock (&g_display_cache_lock); @@ -2031,3 +2034,41 @@ set_color_balance (GstVaapiDisplay * display, guint prop_id, gfloat v) return FALSE; return TRUE; } + +/* Ensures the VA driver vendor string was copied */ +static gboolean +ensure_vendor_string (GstVaapiDisplay * display) +{ + GstVaapiDisplayPrivate *const priv = GST_VAAPI_DISPLAY_GET_PRIVATE (display); + const gchar *vendor_string; + + GST_VAAPI_DISPLAY_LOCK (display); + if (!priv->vendor_string) { + vendor_string = vaQueryVendorString (priv->display); + if (vendor_string) + priv->vendor_string = g_strdup (vendor_string); + } + GST_VAAPI_DISPLAY_UNLOCK (display); + return priv->vendor_string != NULL; +} + +/** + * gst_vaapi_display_get_vendor_string: + * @display: a #GstVaapiDisplay + * + * Returns the VA driver vendor string attached to the supplied VA @display. + * The @display owns the vendor string, do *not* de-allocate it. + * + * This function is thread safe. + * + * Return value: the current #GstVaapiRotation value + */ +const gchar * +gst_vaapi_display_get_vendor_string (GstVaapiDisplay * display) +{ + g_return_val_if_fail (display != NULL, NULL); + + if (!ensure_vendor_string (display)) + return NULL; + return display->priv.vendor_string; +} diff --git a/gst-libs/gst/vaapi/gstvaapidisplay.h b/gst-libs/gst/vaapi/gstvaapidisplay.h index e925a185b7..182350eae0 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplay.h +++ b/gst-libs/gst/vaapi/gstvaapidisplay.h @@ -198,6 +198,9 @@ gboolean gst_vaapi_display_set_rotation (GstVaapiDisplay * display, GstVaapiRotation rotation); +const gchar * +gst_vaapi_display_get_vendor_string (GstVaapiDisplay * display); + G_END_DECLS #endif /* GST_VAAPI_DISPLAY_H */ diff --git a/gst-libs/gst/vaapi/gstvaapidisplay_priv.h b/gst-libs/gst/vaapi/gstvaapidisplay_priv.h index 35f911320c..747387a27d 100644 --- a/gst-libs/gst/vaapi/gstvaapidisplay_priv.h +++ b/gst-libs/gst/vaapi/gstvaapidisplay_priv.h @@ -156,6 +156,7 @@ struct _GstVaapiDisplayPrivate GArray *image_formats; GArray *subpicture_formats; GArray *properties; + gchar *vendor_string; guint use_foreign_display:1; guint has_vpp:1; guint has_profiles:1;