mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2025-01-26 00:58:12 +00:00
vaapivideobufferpool: always update/release the underlying surface proxy
gst_vaapi_video_buffer_pool_reset_buffer() is called when the sink releases the last reference on an exported DMA buffer. This should release the underlying surface proxy. To avoid releasing the wrong surface due to a stale surface proxy reference in the buffer's GstVaapiVideoMeta, always update the reference to the correct surface in gst_vaapi_video_buffer_pool_acquire_buffer().
This commit is contained in:
parent
21dd66b5e4
commit
89f202ea2e
1 changed files with 13 additions and 8 deletions
|
@ -438,6 +438,11 @@ gst_vaapi_video_buffer_pool_acquire_buffer (GstBufferPool * pool,
|
||||||
* the one associated with the current surface. */
|
* the one associated with the current surface. */
|
||||||
g_assert (gst_buffer_n_memory (buffer) == 1);
|
g_assert (gst_buffer_n_memory (buffer) == 1);
|
||||||
|
|
||||||
|
/* Update the underlying surface proxy */
|
||||||
|
meta = gst_buffer_get_vaapi_video_meta (buffer);
|
||||||
|
if (meta)
|
||||||
|
gst_vaapi_video_meta_set_surface_proxy (meta, priv_params->proxy);
|
||||||
|
|
||||||
/* Find the cached memory associated with the given surface. */
|
/* Find the cached memory associated with the given surface. */
|
||||||
surface = GST_VAAPI_SURFACE_PROXY_SURFACE (priv_params->proxy);
|
surface = GST_VAAPI_SURFACE_PROXY_SURFACE (priv_params->proxy);
|
||||||
dmabuf_proxy = gst_vaapi_surface_peek_buffer_proxy (surface);
|
dmabuf_proxy = gst_vaapi_surface_peek_buffer_proxy (surface);
|
||||||
|
@ -449,13 +454,7 @@ gst_vaapi_video_buffer_pool_acquire_buffer (GstBufferPool * pool,
|
||||||
mem = gst_memory_ref (mem);
|
mem = gst_memory_ref (mem);
|
||||||
} else {
|
} else {
|
||||||
/* The given surface has not been exported yet. */
|
/* The given surface has not been exported yet. */
|
||||||
meta = gst_buffer_get_vaapi_video_meta (buffer);
|
mem = gst_vaapi_dmabuf_memory_new (priv->allocator, meta);
|
||||||
if (gst_vaapi_video_meta_get_surface_proxy (meta))
|
|
||||||
gst_vaapi_video_meta_set_surface_proxy (meta, priv_params->proxy);
|
|
||||||
|
|
||||||
mem =
|
|
||||||
gst_vaapi_dmabuf_memory_new (priv->allocator,
|
|
||||||
gst_buffer_get_vaapi_video_meta (buffer));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Attach the GstFdMemory to the output buffer. */
|
/* Attach the GstFdMemory to the output buffer. */
|
||||||
|
@ -475,10 +474,16 @@ gst_vaapi_video_buffer_pool_reset_buffer (GstBufferPool * pool,
|
||||||
GstBuffer * buffer)
|
GstBuffer * buffer)
|
||||||
{
|
{
|
||||||
GstMemory *const mem = gst_buffer_peek_memory (buffer, 0);
|
GstMemory *const mem = gst_buffer_peek_memory (buffer, 0);
|
||||||
|
GstVaapiVideoMeta *meta;
|
||||||
|
|
||||||
/* Release the underlying surface proxy */
|
/* Release the underlying surface proxy */
|
||||||
if (GST_VAAPI_IS_VIDEO_MEMORY (mem))
|
if (GST_VAAPI_IS_VIDEO_MEMORY (mem)) {
|
||||||
gst_vaapi_video_memory_reset_surface (GST_VAAPI_VIDEO_MEMORY_CAST (mem));
|
gst_vaapi_video_memory_reset_surface (GST_VAAPI_VIDEO_MEMORY_CAST (mem));
|
||||||
|
} else {
|
||||||
|
meta = gst_buffer_get_vaapi_video_meta (buffer);
|
||||||
|
if (meta)
|
||||||
|
gst_vaapi_video_meta_set_surface_proxy (meta, NULL);
|
||||||
|
}
|
||||||
|
|
||||||
GST_BUFFER_POOL_CLASS (gst_vaapi_video_buffer_pool_parent_class)->reset_buffer
|
GST_BUFFER_POOL_CLASS (gst_vaapi_video_buffer_pool_parent_class)->reset_buffer
|
||||||
(pool, buffer);
|
(pool, buffer);
|
||||||
|
|
Loading…
Reference in a new issue