mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-04 16:52:40 +08:00
[osal]: add normal mode mpp_buffer path to test and fix a lot of bug
git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@134 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -26,32 +26,17 @@
|
||||
#define MPP_ALLOCATOR_LOCK(p) pthread_mutex_lock(&(p)->lock);
|
||||
#define MPP_ALLOCATOR_UNLOCK(p) pthread_mutex_unlock(&(p)->lock);
|
||||
|
||||
MPP_RET mpp_allocator_alloc(MppAllocator allocator, MppBufferData **data, size_t size)
|
||||
MPP_RET mpp_allocator_alloc(MppAllocator allocator, MppBufferData *data, size_t size)
|
||||
{
|
||||
if (NULL == allocator || NULL == data) {
|
||||
mpp_err("mpp_allocator_alloc invalid input: allocator %p data %p\n",
|
||||
allocator, data);
|
||||
if (NULL == allocator || NULL == data || 0 == size) {
|
||||
mpp_err("mpp_allocator_alloc invalid input: allocator %p data %p size %d\n",
|
||||
allocator, data, size);
|
||||
return MPP_ERR_UNKNOW;
|
||||
}
|
||||
|
||||
if (0 == size) {
|
||||
*data = NULL;
|
||||
return MPP_NOK;
|
||||
}
|
||||
|
||||
MppBufferData *pdata = mpp_malloc(MppBufferData, 1);
|
||||
if (NULL == pdata) {
|
||||
mpp_err("mpp_allocator_alloc failed to alloc MppBufferData\n");
|
||||
*data = NULL;
|
||||
return MPP_ERR_MALLOC;
|
||||
}
|
||||
|
||||
MppAllocatorImpl *palloc = (MppAllocatorImpl *)allocator;
|
||||
MPP_ALLOCATOR_LOCK(palloc);
|
||||
|
||||
int ret = os_allocator_alloc(palloc->allocator, pdata, palloc->alignment, size);
|
||||
*data = pdata;
|
||||
|
||||
int ret = os_allocator_alloc(palloc->allocator, data, size);
|
||||
MPP_ALLOCATOR_UNLOCK(palloc);
|
||||
|
||||
return (0 == ret) ? (MPP_OK) : (MPP_NOK);
|
||||
@@ -70,8 +55,6 @@ MPP_RET mpp_allocator_free(MppAllocator allocator, MppBufferData *data)
|
||||
os_allocator_free(palloc->allocator, data);
|
||||
MPP_ALLOCATOR_UNLOCK(palloc);
|
||||
|
||||
mpp_free(data);
|
||||
|
||||
return MPP_OK;
|
||||
}
|
||||
|
||||
@@ -96,14 +79,14 @@ MPP_RET mpp_alloctor_get(MppAllocator *allocator, MppAllocatorApi **api)
|
||||
return MPP_ERR_NULL_PTR;
|
||||
}
|
||||
|
||||
os_allocator_open(&palloc->allocator);
|
||||
palloc->alignment = SZ_4K;
|
||||
os_allocator_open(&palloc->allocator, palloc->alignment);
|
||||
|
||||
papi->size = sizeof(papi->size);
|
||||
papi->version = 1;
|
||||
papi->alloc = mpp_allocator_alloc;
|
||||
papi->free = mpp_allocator_free;
|
||||
|
||||
palloc->api = papi;
|
||||
palloc->alignment = SZ_4K;
|
||||
|
||||
pthread_mutexattr_t attr;
|
||||
pthread_mutexattr_init(&attr);
|
||||
|
Reference in New Issue
Block a user