guard buffer export API if not available

The support for buffer exports in VA-API was added in version 0.36. These
interfaces are for interop with EGL, OpenCL, etc.

GStreamer-VAAPI uses it for a dmabuf memory allocator. Though, gstreamer-vaapi
has to support VA-API versions ranging from 0.30.4, which doesn't support it.

This patch guards all the buffer exports handling (and dmabuf allocator) if
the detected VA-API version is below 0.36.

https://bugzilla.gnome.org/show_bug.cgi?id=746405
This commit is contained in:
Víctor Manuel Jáquez Leal 2015-04-08 18:05:20 +02:00
parent c750fa937d
commit 38f8fea4bb
3 changed files with 27 additions and 1 deletions

View file

@ -77,6 +77,7 @@ to_GstVaapiBufferMemoryType (guint va_type)
static gboolean static gboolean
gst_vaapi_buffer_proxy_acquire_handle (GstVaapiBufferProxy * proxy) gst_vaapi_buffer_proxy_acquire_handle (GstVaapiBufferProxy * proxy)
{ {
#if VA_CHECK_VERSION (0,36,0)
const guint mem_type = proxy->va_info.mem_type; const guint mem_type = proxy->va_info.mem_type;
VAStatus va_status; VAStatus va_status;
@ -95,11 +96,15 @@ gst_vaapi_buffer_proxy_acquire_handle (GstVaapiBufferProxy * proxy)
if (proxy->va_info.mem_type != mem_type) if (proxy->va_info.mem_type != mem_type)
return FALSE; return FALSE;
return TRUE; return TRUE;
#else
return FALSE;
#endif
} }
static gboolean static gboolean
gst_vaapi_buffer_proxy_release_handle (GstVaapiBufferProxy * proxy) gst_vaapi_buffer_proxy_release_handle (GstVaapiBufferProxy * proxy)
{ {
#if VA_CHECK_VERSION (0,36,0)
VAStatus va_status; VAStatus va_status;
if (!proxy->va_info.handle) if (!proxy->va_info.handle)
@ -115,6 +120,9 @@ gst_vaapi_buffer_proxy_release_handle (GstVaapiBufferProxy * proxy)
if (!vaapi_check_status (va_status, "vaReleaseBufferHandle()")) if (!vaapi_check_status (va_status, "vaReleaseBufferHandle()"))
return FALSE; return FALSE;
return TRUE; return TRUE;
#else
return FALSE;
#endif
} }
static void static void
@ -143,6 +151,7 @@ GstVaapiBufferProxy *
gst_vaapi_buffer_proxy_new (guintptr handle, guint type, gsize size, gst_vaapi_buffer_proxy_new (guintptr handle, guint type, gsize size,
GDestroyNotify destroy_func, gpointer user_data) GDestroyNotify destroy_func, gpointer user_data)
{ {
#if VA_CHECK_VERSION (0,36,0)
GstVaapiBufferProxy *proxy; GstVaapiBufferProxy *proxy;
g_return_val_if_fail (handle != 0, NULL); g_return_val_if_fail (handle != 0, NULL);
@ -171,12 +180,16 @@ error_unsupported_mem_type:
GST_ERROR ("unsupported buffer type (%d)", proxy->type); GST_ERROR ("unsupported buffer type (%d)", proxy->type);
gst_vaapi_buffer_proxy_unref_internal (proxy); gst_vaapi_buffer_proxy_unref_internal (proxy);
return NULL; return NULL;
#else
return NULL;
#endif
} }
GstVaapiBufferProxy * GstVaapiBufferProxy *
gst_vaapi_buffer_proxy_new_from_object (GstVaapiObject * object, gst_vaapi_buffer_proxy_new_from_object (GstVaapiObject * object,
VABufferID buf_id, guint type, GDestroyNotify destroy_func, gpointer data) VABufferID buf_id, guint type, GDestroyNotify destroy_func, gpointer data)
{ {
#if VA_CHECK_VERSION (0,36,0)
GstVaapiBufferProxy *proxy; GstVaapiBufferProxy *proxy;
g_return_val_if_fail (object != NULL, NULL); g_return_val_if_fail (object != NULL, NULL);
@ -208,6 +221,9 @@ error_acquire_handle:
GST_ERROR ("failed to acquire the underlying VA buffer handle"); GST_ERROR ("failed to acquire the underlying VA buffer handle");
gst_vaapi_buffer_proxy_unref_internal (proxy); gst_vaapi_buffer_proxy_unref_internal (proxy);
return NULL; return NULL;
#else
return NULL;
#endif
} }
/** /**
@ -288,7 +304,11 @@ gst_vaapi_buffer_proxy_get_handle (GstVaapiBufferProxy * proxy)
{ {
g_return_val_if_fail (proxy != NULL, 0); g_return_val_if_fail (proxy != NULL, 0);
#if VA_CHECK_VERSION (0,36,0)
return GST_VAAPI_BUFFER_PROXY_HANDLE (proxy); return GST_VAAPI_BUFFER_PROXY_HANDLE (proxy);
#else
return 0;
#endif
} }
/** /**
@ -304,5 +324,9 @@ gst_vaapi_buffer_proxy_get_size (GstVaapiBufferProxy * proxy)
{ {
g_return_val_if_fail (proxy != NULL, 0); g_return_val_if_fail (proxy != NULL, 0);
#if VA_CHECK_VERSION (0,36,0)
return GST_VAAPI_BUFFER_PROXY_SIZE (proxy); return GST_VAAPI_BUFFER_PROXY_SIZE (proxy);
#else
return 0;
#endif
} }

View file

@ -68,7 +68,9 @@ struct _GstVaapiBufferProxy {
gpointer destroy_data; gpointer destroy_data;
guint type; guint type;
VABufferID va_buf; VABufferID va_buf;
#if VA_CHECK_VERSION (0,36,0)
VABufferInfo va_info; VABufferInfo va_info;
#endif
}; };
G_GNUC_INTERNAL G_GNUC_INTERNAL

View file

@ -225,7 +225,7 @@ static gboolean
gst_vaapi_surface_create_from_buffer_proxy (GstVaapiSurface * surface, gst_vaapi_surface_create_from_buffer_proxy (GstVaapiSurface * surface,
GstVaapiBufferProxy * proxy, const GstVideoInfo * vip) GstVaapiBufferProxy * proxy, const GstVideoInfo * vip)
{ {
#if VA_CHECK_VERSION (0,34,0) #if VA_CHECK_VERSION (0,36,0)
GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (surface); GstVaapiDisplay *const display = GST_VAAPI_OBJECT_DISPLAY (surface);
GstVideoFormat format; GstVideoFormat format;
VASurfaceID surface_id; VASurfaceID surface_id;