mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-29 21:21:12 +00:00
allocators: drm-dumb: Fix non-thread safe dmabuf allocator creation
If the allocation function get called from multiple threads at the same time, multiple allocators may get created but only one get saved. Leading to other allocators to be leaked. Simply create it once in the instance initialization. Fixes: #2456 Part-of: <https://gitlab.freedesktop.org/gstreamer/gstreamer/-/merge_requests/6052>
This commit is contained in:
parent
39f2afbd45
commit
0fd76c2848
1 changed files with 2 additions and 5 deletions
|
@ -156,9 +156,6 @@ gst_drm_dumb_memory_export_dmabuf (GstMemory * mem)
|
|||
if (ret)
|
||||
goto export_fd_failed;
|
||||
|
||||
if (G_UNLIKELY (alloc->dmabuf_alloc == NULL))
|
||||
alloc->dmabuf_alloc = gst_dmabuf_allocator_new ();
|
||||
|
||||
dmamem = gst_dmabuf_allocator_alloc (alloc->dmabuf_alloc, prime_fd,
|
||||
gst_memory_get_sizes (mem, NULL, NULL));
|
||||
|
||||
|
@ -452,7 +449,6 @@ gst_drm_dumb_allocator_finalize (GObject * obj)
|
|||
{
|
||||
GstDRMDumbAllocator *alloc = GST_DRM_DUMB_ALLOCATOR (obj);
|
||||
|
||||
if (alloc->dmabuf_alloc)
|
||||
gst_object_unref (alloc->dmabuf_alloc);
|
||||
|
||||
g_free (alloc->drm_device_path);
|
||||
|
@ -581,6 +577,7 @@ gst_drm_dumb_allocator_init (GstDRMDumbAllocator * alloc)
|
|||
|
||||
alloc->drm_fd = -1;
|
||||
alloc->drm_device_path = NULL;
|
||||
alloc->dmabuf_alloc = gst_dmabuf_allocator_new ();
|
||||
|
||||
base_alloc->mem_type = GST_DRM_DUMB_MEMORY_TYPE;
|
||||
base_alloc->mem_map = gst_drm_dumb_memory_map;
|
||||
|
|
Loading…
Reference in a new issue