msdk: fix memory leaks in msdk allocators
This commit is contained in:
parent
9b2dc96b99
commit
3b171f70af
@ -199,13 +199,21 @@ gst_msdk_system_memory_new (GstAllocator * base_allocator)
|
|||||||
|
|
||||||
mem->surface = gst_msdk_system_allocator_create_surface (base_allocator);
|
mem->surface = gst_msdk_system_allocator_create_surface (base_allocator);
|
||||||
|
|
||||||
|
if (!mem->surface) {
|
||||||
|
g_slice_free (GstMsdkSystemMemory, mem);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
vip = &allocator->image_info;
|
vip = &allocator->image_info;
|
||||||
gst_memory_init (&mem->parent_instance, 0,
|
gst_memory_init (&mem->parent_instance, 0,
|
||||||
base_allocator, NULL, GST_VIDEO_INFO_SIZE (vip), 0, 0,
|
base_allocator, NULL, GST_VIDEO_INFO_SIZE (vip), 0, 0,
|
||||||
GST_VIDEO_INFO_SIZE (vip));
|
GST_VIDEO_INFO_SIZE (vip));
|
||||||
|
|
||||||
if (!ensure_data (mem))
|
if (!ensure_data (mem)) {
|
||||||
|
g_slice_free (mfxFrameSurface1, mem->surface);
|
||||||
|
g_slice_free (GstMsdkSystemMemory, mem);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return GST_MEMORY_CAST (mem);
|
return GST_MEMORY_CAST (mem);
|
||||||
}
|
}
|
||||||
@ -278,6 +286,7 @@ gst_msdk_system_allocator_free (GstAllocator * allocator, GstMemory * base_mem)
|
|||||||
|
|
||||||
_aligned_free (mem->cache);
|
_aligned_free (mem->cache);
|
||||||
g_slice_free (mfxFrameSurface1, mem->surface);
|
g_slice_free (mfxFrameSurface1, mem->surface);
|
||||||
|
g_slice_free (GstMsdkSystemMemory, mem);
|
||||||
}
|
}
|
||||||
|
|
||||||
static GstMemory *
|
static GstMemory *
|
||||||
|
@ -166,8 +166,10 @@ gst_msdk_video_memory_new (GstAllocator * base_allocator)
|
|||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
mem->surface = gst_msdk_video_allocator_get_surface (base_allocator);
|
mem->surface = gst_msdk_video_allocator_get_surface (base_allocator);
|
||||||
if (!mem->surface)
|
if (!mem->surface) {
|
||||||
|
g_slice_free (GstMsdkVideoMemory, mem);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
vip = &allocator->image_info;
|
vip = &allocator->image_info;
|
||||||
gst_memory_init (&mem->parent_instance, 0,
|
gst_memory_init (&mem->parent_instance, 0,
|
||||||
@ -365,6 +367,14 @@ gst_msdk_video_allocator_finalize (GObject * object)
|
|||||||
G_OBJECT_CLASS (gst_msdk_video_allocator_parent_class)->finalize (object);
|
G_OBJECT_CLASS (gst_msdk_video_allocator_parent_class)->finalize (object);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
gst_msdk_video_allocator_free (GstAllocator * allocator, GstMemory * base_mem)
|
||||||
|
{
|
||||||
|
GstMsdkVideoMemory *const mem = GST_MSDK_VIDEO_MEMORY_CAST (base_mem);
|
||||||
|
|
||||||
|
g_slice_free (GstMsdkVideoMemory, mem);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
gst_msdk_video_allocator_class_init (GstMsdkVideoAllocatorClass * klass)
|
gst_msdk_video_allocator_class_init (GstMsdkVideoAllocatorClass * klass)
|
||||||
{
|
{
|
||||||
@ -374,6 +384,7 @@ gst_msdk_video_allocator_class_init (GstMsdkVideoAllocatorClass * klass)
|
|||||||
object_class->finalize = gst_msdk_video_allocator_finalize;
|
object_class->finalize = gst_msdk_video_allocator_finalize;
|
||||||
|
|
||||||
allocator_class->alloc = gst_msdk_video_allocator_alloc;
|
allocator_class->alloc = gst_msdk_video_allocator_alloc;
|
||||||
|
allocator_class->free = gst_msdk_video_allocator_free;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
|
Loading…
x
Reference in New Issue
Block a user