xref: /OK3568_Linux_fs/external/mpp/osal/os_allocator.h (revision 4882a59341e53eb6f0b4789bf948001014eff981)
1 /*
2  * Copyright 2015 Rockchip Electronics Co. LTD
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #ifndef __OS_ALLOCATOR_H__
18 #define __OS_ALLOCATOR_H__
19 
20 #include "mpp_allocator.h"
21 
22 typedef MPP_RET (*OsAllocatorFunc)(void *ctx, MppBufferInfo *info);
23 
24 typedef struct os_allocator_t {
25     MppBufferType type;
26 
27     MPP_RET (*open)(void **ctx, MppAllocatorCfg *cfg);
28     MPP_RET (*close)(void *ctx);
29 
30     OsAllocatorFunc alloc;
31     OsAllocatorFunc free;
32     OsAllocatorFunc import;
33     OsAllocatorFunc release;
34     OsAllocatorFunc mmap;
35 } os_allocator;
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 MPP_RET os_allocator_get(os_allocator *api, MppBufferType type);
42 
43 #ifdef __cplusplus
44 }
45 #endif
46 
47 #endif /*__OS_ALLOCATOR_H__*/
48 
49 
50