[allocator]: fix dma_heap allocator

segment fault happened in mpp_allocator_put.
 #00 pc 00102e14  /vendor/lib/libmpp.so (mpp_allocator_put+272)
 #01 pc 0004705c  /vendor/lib/libmpp.so (MppBufferService::~MppBufferService()+536)

Signed-off-by: xueman.ruan <xueman.ruan@rock-chips.com>
Change-Id: Ia4f9a3b4823bf6a5d8f3fdfd85055630222c0b43
This commit is contained in:
xueman.ruan
2022-07-01 14:53:21 +08:00
committed by Herman Chen
parent def09cb3c2
commit 652e18fcf0
3 changed files with 8 additions and 2 deletions

View File

@@ -49,7 +49,8 @@ MPP_RET os_allocator_get(os_allocator *api, MppBufferType type)
allocator_std;
} break;
case MPP_BUFFER_TYPE_DMA_HEAP: {
*api = allocator_dma_heap;
*api = (mpp_rt_allcator_is_valid(MPP_BUFFER_TYPE_DMA_HEAP)) ? allocator_dma_heap :
allocator_std;
} break;
default : {
ret = MPP_NOK;

View File

@@ -56,7 +56,8 @@ MPP_RET os_allocator_get(os_allocator *api, MppBufferType type)
allocator_std;
} break;
case MPP_BUFFER_TYPE_DMA_HEAP: {
*api = allocator_dma_heap;
*api = (mpp_rt_allcator_is_valid(MPP_BUFFER_TYPE_DMA_HEAP)) ? allocator_dma_heap :
allocator_std;
} break;
default : {
ret = MPP_NOK;

View File

@@ -176,7 +176,11 @@ MPP_RET mpp_allocator_put(MppAllocator *allocator)
}
MppAllocatorImpl *p = (MppAllocatorImpl *)*allocator;
if (!p)
return MPP_OK;
*allocator = NULL;
if (p->os_api.close && p->ctx)
p->os_api.close(p->ctx);
pthread_mutex_destroy(&p->lock);