[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:
ChenHengming
2015-08-20 03:23:36 +00:00
parent e78f44b2fb
commit 2e5aafaf44
9 changed files with 179 additions and 82 deletions

View File

@@ -14,21 +14,50 @@
* limitations under the License.
*/
#include <stdlib.h>
#include <stdio.h>
#include "os_mem.h"
#include "os_allocator.h"
int os_allocator_open(void **ctx)
#include "mpp_mem.h"
#include "mpp_log.h"
typedef struct {
size_t alignment;
} allocator_impl;
int os_allocator_open(void **ctx, size_t alignment)
{
if (ctx)
allocator_impl *p = NULL;
if (NULL == ctx) {
mpp_err("os_allocator_open Linux do not accept NULL input\n");
return MPP_ERR_NULL_PTR;
}
p = mpp_malloc(allocator_impl, 1);
if (NULL == p) {
*ctx = NULL;
return 0;
mpp_err("os_allocator_open Linux failed to allocate context\n");
return MPP_ERR_MALLOC;
}
p->alignment = alignment;
*ctx = p;
return MPP_OK;
}
int os_allocator_alloc(void *ctx, MppBufferData *data, size_t alignment, size_t size)
int os_allocator_alloc(void *ctx, MppBufferData *data, size_t size)
{
(void) ctx;
return os_malloc(&data->ptr, alignment, size);
allocator_impl *p = NULL;
if (NULL == ctx) {
mpp_err("os_allocator_alloc Linux found NULL context input\n");
return MPP_ERR_NULL_PTR;
}
p = (allocator_impl *)ctx;
return os_malloc(&data->ptr, p->alignment, size);
}
void os_allocator_free(void *ctx, MppBufferData *data)
@@ -39,6 +68,9 @@ void os_allocator_free(void *ctx, MppBufferData *data)
void os_allocator_close(void *ctx)
{
(void) ctx;
if (ctx)
mpp_free(ctx);
else
mpp_err("os_allocator_close Linux found NULL context input\n");
}