va: allocator: user gst_clear_object() for _buffer_surface_unref()

Event if this function is only used by gst_va_dmabuf_memories_setup(), it might
get reused later by GstVaDmabufAllocator's functions. This change makes the
function less fragile.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1626>
This commit is contained in:
Víctor Manuel Jáquez Leal 2020-09-30 15:54:18 +02:00 committed by GStreamer Merge Bot
parent 10b3250175
commit d6f9cfc159

View file

@ -438,7 +438,7 @@ _buffer_surface_unref (gpointer data)
if (g_atomic_int_dec_and_test (&buf->ref_count)) { if (g_atomic_int_dec_and_test (&buf->ref_count)) {
GST_LOG_OBJECT (buf->display, "Destroying surface %#x", buf->surface); GST_LOG_OBJECT (buf->display, "Destroying surface %#x", buf->surface);
_destroy_surfaces (buf->display, &buf->surface, 1); _destroy_surfaces (buf->display, &buf->surface, 1);
gst_object_unref (buf->display); gst_clear_object (&buf->display);
g_slice_free (GstVaBufferSurface, buf); g_slice_free (GstVaBufferSurface, buf);
} }
} }
@ -451,6 +451,7 @@ _create_buffer_surface (VASurfaceID surface, GstVideoFormat format,
g_atomic_int_set (&buf->ref_count, 0); g_atomic_int_set (&buf->ref_count, 0);
buf->surface = surface; buf->surface = surface;
buf->display = NULL;
gst_video_info_set_format (&buf->info, format, width, height); gst_video_info_set_format (&buf->info, format, width, height);
return buf; return buf;