summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGwenole Beauchesne <gwenole.beauchesne@intel.com>2013-10-09 09:47:18 +0200
committerGwenole Beauchesne <gwenole.beauchesne@intel.com>2013-10-09 18:30:06 +0200
commitf361d4a23d38ae180cdfbcaea9abddc7dc74aeca (patch)
treee9a6fd4580eeed5bb34e236c5f49f884c3571233
parent4df68163dcd5f58e7b7e9bf6909d61be1658f30c (diff)
plugins: fix buffer pool reset_buffer() to reset memory resources.
Fix GstVaapiVideoBufferPool::reset_buffer() to reset the underlying memory resources, and more particularly the VA surface proxy. Most importantly, the GstVaapiVideoMeta is retained. Cached surface in memory are released, thus triggering a new allocation the next time we need to map the buffer.
-rw-r--r--gst/vaapi/gstvaapivideobufferpool.c4
-rw-r--r--gst/vaapi/gstvaapivideomemory.c10
-rw-r--r--gst/vaapi/gstvaapivideomemory.h4
3 files changed, 16 insertions, 2 deletions
diff --git a/gst/vaapi/gstvaapivideobufferpool.c b/gst/vaapi/gstvaapivideobufferpool.c
index fdcc360e..d9612a6b 100644
--- a/gst/vaapi/gstvaapivideobufferpool.c
+++ b/gst/vaapi/gstvaapivideobufferpool.c
@@ -234,10 +234,10 @@ error_create_memory:
static void
gst_vaapi_video_buffer_pool_reset_buffer(GstBufferPool *pool, GstBuffer *buffer)
{
- GstVaapiVideoMeta * const meta = gst_buffer_get_vaapi_video_meta(buffer);
+ GstMemory * const mem = gst_buffer_peek_memory(buffer, 0);
/* Release the underlying surface proxy */
- gst_vaapi_video_meta_set_surface_proxy(meta, NULL);
+ gst_vaapi_video_memory_reset_surface(GST_VAAPI_VIDEO_MEMORY_CAST(mem));
GST_BUFFER_POOL_CLASS(gst_vaapi_video_buffer_pool_parent_class)->
reset_buffer(pool, buffer);
diff --git a/gst/vaapi/gstvaapivideomemory.c b/gst/vaapi/gstvaapivideomemory.c
index e50d2f90..319d2574 100644
--- a/gst/vaapi/gstvaapivideomemory.c
+++ b/gst/vaapi/gstvaapivideomemory.c
@@ -258,6 +258,16 @@ gst_vaapi_video_memory_free(GstVaapiVideoMemory *mem)
g_slice_free(GstVaapiVideoMemory, mem);
}
+void
+gst_vaapi_video_memory_reset_surface(GstVaapiVideoMemory *mem)
+{
+ mem->surface = NULL;
+ gst_vaapi_surface_proxy_replace(&mem->proxy, NULL);
+ if (mem->use_direct_rendering)
+ gst_vaapi_object_replace(&mem->image, NULL);
+ gst_vaapi_video_meta_set_surface_proxy(mem->meta, NULL);
+}
+
static gpointer
gst_vaapi_video_memory_map(GstVaapiVideoMemory *mem, gsize maxsize, guint flags)
{
diff --git a/gst/vaapi/gstvaapivideomemory.h b/gst/vaapi/gstvaapivideomemory.h
index c4bd5fdd..dac44586 100644
--- a/gst/vaapi/gstvaapivideomemory.h
+++ b/gst/vaapi/gstvaapivideomemory.h
@@ -96,6 +96,10 @@ gboolean
gst_video_meta_unmap_vaapi_memory(GstVideoMeta *meta, guint plane,
GstMapInfo *info);
+G_GNUC_INTERNAL
+void
+gst_vaapi_video_memory_reset_surface(GstVaapiVideoMemory *mem);
+
/* ------------------------------------------------------------------------ */
/* --- GstVaapiVideoAllocator --- */
/* ------------------------------------------------------------------------ */