display: add utility function to query VA driver name.
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>
Tue, 20 May 2014 09:36:40 +0000 (11:36 +0200)
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>
Wed, 21 May 2014 17:59:52 +0000 (19:59 +0200)
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
gst-libs/gst/vaapi/gstvaapidisplay.h
gst-libs/gst/vaapi/gstvaapidisplay_priv.h

index 776ab68..64f0245 100644 (file)
@@ -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;
+}
index e925a18..182350e 100644 (file)
@@ -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 */
index 35f9113..747387a 100644 (file)
@@ -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;