[allocator]: add import and release function to os/mpp allocator

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@339 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
ChenHengming
2015-10-09 21:59:41 +00:00
parent c157fecb65
commit e3f49b11aa
7 changed files with 83 additions and 5 deletions

View File

@@ -29,7 +29,7 @@
MPP_RET mpp_allocator_alloc(MppAllocator allocator, MppBufferInfo *info)
{
if (NULL == allocator || NULL == info) {
mpp_err("mpp_allocator_alloc invalid input: allocator %p info %p\n",
mpp_err_f("invalid input: allocator %p info %p\n",
allocator, info);
return MPP_ERR_UNKNOW;
}
@@ -47,7 +47,7 @@ MPP_RET mpp_allocator_alloc(MppAllocator allocator, MppBufferInfo *info)
MPP_RET mpp_allocator_free(MppAllocator allocator, MppBufferInfo *info)
{
if (NULL == allocator || NULL == info) {
mpp_err("mpp_allocator_alloc invalid input: allocator %p info %p\n",
mpp_err_f("invalid input: allocator %p info %p\n",
allocator, info);
return MPP_ERR_UNKNOW;
}
@@ -62,11 +62,51 @@ MPP_RET mpp_allocator_free(MppAllocator allocator, MppBufferInfo *info)
return ret;
}
MPP_RET mpp_allocator_import(MppAllocator allocator, MppBufferInfo *info)
{
if (NULL == info) {
mpp_err_f("invalid input: info %p\n", info);
return MPP_ERR_UNKNOW;
}
MPP_RET ret = MPP_OK;
MppAllocatorImpl *p = (MppAllocatorImpl *)allocator;
if (p->os_api.import) {
MPP_ALLOCATOR_LOCK(p);
ret = p->os_api.import(p->ctx, info);
MPP_ALLOCATOR_UNLOCK(p);
}
return ret;
}
MPP_RET mpp_allocator_release(MppAllocator allocator, MppBufferInfo *info)
{
if (NULL == allocator || NULL == info) {
mpp_err("mpp_allocator_alloc invalid input: allocator %p info %p\n",
allocator, info);
return MPP_ERR_UNKNOW;
}
MPP_RET ret = MPP_OK;
MppAllocatorImpl *p = (MppAllocatorImpl *)allocator;
if (p->os_api.release) {
MPP_ALLOCATOR_LOCK(p);
ret = p->os_api.release(p->ctx, info);
MPP_ALLOCATOR_UNLOCK(p);
}
return ret;
}
static MppAllocatorApi mpp_allocator_api = {
sizeof(mpp_allocator_api),
1,
mpp_allocator_alloc,
mpp_allocator_free,
mpp_allocator_import,
mpp_allocator_release,
};
MPP_RET mpp_alloctor_get(MppAllocator *allocator, MppAllocatorApi **api, MppBufferType type)