[mpp_buffer]: fix mpp_buffer_test error on Android for normal buffer can not be import/release

git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@971 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
ChenHengming
2016-07-01 04:48:52 +00:00
parent 981d51187b
commit c9d4080335

View File

@@ -28,6 +28,7 @@
typedef struct { typedef struct {
RK_U32 alignment; RK_U32 alignment;
RK_S32 fd_count;
} allocator_ctx_normal; } allocator_ctx_normal;
MPP_RET os_allocator_normal_open(void **ctx, size_t alignment) MPP_RET os_allocator_normal_open(void **ctx, size_t alignment)
@@ -47,6 +48,8 @@ MPP_RET os_allocator_normal_open(void **ctx, size_t alignment)
} else } else
p->alignment = alignment; p->alignment = alignment;
p->fd_count = 0;
*ctx = p; *ctx = p;
return ret; return ret;
} }
@@ -61,6 +64,7 @@ MPP_RET os_allocator_normal_alloc(void *ctx, MppBufferInfo *info)
} }
p = (allocator_ctx_normal *)ctx; p = (allocator_ctx_normal *)ctx;
info->fd = p->fd_count++;
return os_malloc(&info->ptr, p->alignment, info->size); return os_malloc(&info->ptr, p->alignment, info->size);
} }
@@ -72,6 +76,29 @@ MPP_RET os_allocator_normal_free(void *ctx, MppBufferInfo *info)
return MPP_OK; return MPP_OK;
} }
MPP_RET os_allocator_normal_import(void *ctx, MppBufferInfo *info)
{
allocator_ctx_normal *p = (allocator_ctx_normal *)ctx;
mpp_assert(ctx);
mpp_assert(info->ptr);
mpp_assert(info->size);
info->hnd = NULL;
info->fd = p->fd_count++;
return MPP_OK;
}
MPP_RET os_allocator_normal_release(void *ctx, MppBufferInfo *info)
{
(void) ctx;
mpp_assert(info->ptr);
mpp_assert(info->size);
info->ptr = NULL;
info->size = 0;
info->hnd = NULL;
info->fd = -1;
return MPP_OK;
}
MPP_RET os_allocator_normal_close(void *ctx) MPP_RET os_allocator_normal_close(void *ctx)
{ {
if (ctx) { if (ctx) {
@@ -86,8 +113,8 @@ static os_allocator allocator_normal = {
os_allocator_normal_open, os_allocator_normal_open,
os_allocator_normal_alloc, os_allocator_normal_alloc,
os_allocator_normal_free, os_allocator_normal_free,
NULL, os_allocator_normal_import,
NULL, os_allocator_normal_release,
os_allocator_normal_close, os_allocator_normal_close,
}; };