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.
This commit is contained in:
Gwenole Beauchesne 2013-10-09 09:47:18 +02:00
parent 4df68163dc
commit f361d4a23d
3 changed files with 16 additions and 2 deletions

View file

@ -234,10 +234,10 @@ error_create_memory:
static void static void
gst_vaapi_video_buffer_pool_reset_buffer(GstBufferPool *pool, GstBuffer *buffer) 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 */ /* 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)-> GST_BUFFER_POOL_CLASS(gst_vaapi_video_buffer_pool_parent_class)->
reset_buffer(pool, buffer); reset_buffer(pool, buffer);

View file

@ -258,6 +258,16 @@ gst_vaapi_video_memory_free(GstVaapiVideoMemory *mem)
g_slice_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 static gpointer
gst_vaapi_video_memory_map(GstVaapiVideoMemory *mem, gsize maxsize, guint flags) gst_vaapi_video_memory_map(GstVaapiVideoMemory *mem, gsize maxsize, guint flags)
{ {

View file

@ -96,6 +96,10 @@ gboolean
gst_video_meta_unmap_vaapi_memory(GstVideoMeta *meta, guint plane, gst_video_meta_unmap_vaapi_memory(GstVideoMeta *meta, guint plane,
GstMapInfo *info); GstMapInfo *info);
G_GNUC_INTERNAL
void
gst_vaapi_video_memory_reset_surface(GstVaapiVideoMemory *mem);
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */
/* --- GstVaapiVideoAllocator --- */ /* --- GstVaapiVideoAllocator --- */
/* ------------------------------------------------------------------------ */ /* ------------------------------------------------------------------------ */