mirror of
https://github.com/nyanmisaka/mpp.git
synced 2025-10-05 01:02:39 +08:00
[osal]: add mpp_allocator to mpp_buffer_impl
git-svn-id: https://10.10.10.66:8443/svn/MediaProcessPlatform/trunk/mpp@131 6e48237b-75ef-9749-8fc9-41990f28c85a
This commit is contained in:
@@ -20,7 +20,6 @@
|
|||||||
|
|
||||||
#include "mpp_log.h"
|
#include "mpp_log.h"
|
||||||
#include "mpp_mem.h"
|
#include "mpp_mem.h"
|
||||||
#include "mpp_allocator.h"
|
|
||||||
#include "mpp_buffer_impl.h"
|
#include "mpp_buffer_impl.h"
|
||||||
|
|
||||||
#define MPP_BUFFER_SERVICE_LOCK() pthread_mutex_lock(&services.lock)
|
#define MPP_BUFFER_SERVICE_LOCK() pthread_mutex_lock(&services.lock)
|
||||||
@@ -243,6 +242,8 @@ MPP_RET mpp_buffer_group_init(MppBufferGroupImpl **group, const char *tag, MppBu
|
|||||||
break;
|
break;
|
||||||
} while (p->group_id != services.group_count);
|
} while (p->group_id != services.group_count);
|
||||||
|
|
||||||
|
mpp_alloctor_get(&p->allocator, &p->api);
|
||||||
|
|
||||||
MPP_BUFFER_SERVICE_UNLOCK();
|
MPP_BUFFER_SERVICE_UNLOCK();
|
||||||
*group = p;
|
*group = p;
|
||||||
|
|
||||||
@@ -274,6 +275,8 @@ MPP_RET mpp_buffer_group_deinit(MppBufferGroupImpl *p)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
mpp_alloctor_put(&p->allocator);
|
||||||
|
|
||||||
list_del_init(&p->list_group);
|
list_del_init(&p->list_group);
|
||||||
services.group_count--;
|
services.group_count--;
|
||||||
|
|
||||||
|
@@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
#include "mpp_list.h"
|
#include "mpp_list.h"
|
||||||
#include "mpp_common.h"
|
#include "mpp_common.h"
|
||||||
#include "mpp_buffer.h"
|
#include "mpp_allocator.h"
|
||||||
|
|
||||||
#define MPP_BUF_DBG_FUNCTION (0x00000001)
|
#define MPP_BUF_DBG_FUNCTION (0x00000001)
|
||||||
|
|
||||||
@@ -53,6 +53,9 @@ struct MppBufferGroupImpl_t {
|
|||||||
size_t limit;
|
size_t limit;
|
||||||
size_t usage;
|
size_t usage;
|
||||||
|
|
||||||
|
MppAllocator allocator;
|
||||||
|
MppAllocatorApi *api;
|
||||||
|
|
||||||
// link to the other MppBufferGroupImpl
|
// link to the other MppBufferGroupImpl
|
||||||
struct list_head list_group;
|
struct list_head list_group;
|
||||||
|
|
||||||
|
@@ -18,6 +18,13 @@
|
|||||||
#include "os_mem.h"
|
#include "os_mem.h"
|
||||||
#include "os_allocator.h"
|
#include "os_allocator.h"
|
||||||
|
|
||||||
|
int os_allocator_open(void **ctx)
|
||||||
|
{
|
||||||
|
if (ctx)
|
||||||
|
*ctx = NULL;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int os_allocator_alloc(void *ctx, MppBufferData *data, size_t alignment, size_t size)
|
int os_allocator_alloc(void *ctx, MppBufferData *data, size_t alignment, size_t size)
|
||||||
{
|
{
|
||||||
(void) ctx;
|
(void) ctx;
|
||||||
@@ -30,3 +37,8 @@ void os_allocator_free(void *ctx, MppBufferData *data)
|
|||||||
os_free(data->ptr);
|
os_free(data->ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void os_allocator_close(void *ctx)
|
||||||
|
{
|
||||||
|
(void) ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -115,6 +115,9 @@ MPP_RET mpp_alloctor_get(MppAllocator *allocator, MppAllocatorApi **api)
|
|||||||
pthread_mutex_init(&palloc->lock, &attr);
|
pthread_mutex_init(&palloc->lock, &attr);
|
||||||
pthread_mutexattr_destroy(&attr);
|
pthread_mutexattr_destroy(&attr);
|
||||||
|
|
||||||
|
*allocator = palloc;
|
||||||
|
*api = papi;
|
||||||
|
|
||||||
return MPP_OK;
|
return MPP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -17,6 +17,13 @@
|
|||||||
#include "os_mem.h"
|
#include "os_mem.h"
|
||||||
#include "os_allocator.h"
|
#include "os_allocator.h"
|
||||||
|
|
||||||
|
int os_allocator_open(void **ctx)
|
||||||
|
{
|
||||||
|
if (ctx)
|
||||||
|
*ctx = NULL;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
int os_allocator_alloc(void *ctx, MppBufferData *data, size_t alignment, size_t size)
|
int os_allocator_alloc(void *ctx, MppBufferData *data, size_t alignment, size_t size)
|
||||||
{
|
{
|
||||||
(void) ctx;
|
(void) ctx;
|
||||||
@@ -29,3 +36,8 @@ void os_allocator_free(void *ctx, MppBufferData *data)
|
|||||||
os_free(data->ptr);
|
os_free(data->ptr);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void os_allocator_close(void *ctx)
|
||||||
|
{
|
||||||
|
(void) ctx;
|
||||||
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user