hbmem sample
功能概述
hbmem api使用说明,包括com buffer、graphic buffer、graphic buffer group、queue、pool、share pool的创建使用,多进程共享等。
软件架构说明
本sample基于libhbmem API实现,调用libhbmem提供的API,实现不同buffer类型的内存申请和进程间共享。
代码位置及目录结构
1. 代码位置:/app/communication_demo/hbmem_demo/sample_hbmem
2. 目录结构:
./
├── Makefile
├── sample_alloc.c
├── sample.c
├── sample_common.c
├── sample_common.h
├── sample_pool.c
├── sample_queue.c
├── sample_share.c
└── sample_share_pool.c
API流程说明
libhbmem库调用ion进行buffer分配
![hbmem_sample_call_sequence]https://rdk-doc.oss-cn-beijing.aliyuncs.com/doc/img/07_Advanced_development/03_multimedia_development/02 _S100/hbmem/hbmem_sample_call_sequence.png)
com buffer、graph buffer、graphic buffer group 分配流程图
queue使用流程图
pool使用流程图
share pool 使用流程图
编译
编译环境
本sample支持在板端直接编译。
编译说明
本sample主要依赖libhbmem提供的头文件:
#include <hb_mem_mgr.h>
#include <hb_mem_err.h>
编译依赖的库有如下:
LIBS += -lhbmem -lpthread -lalog -ldl -lstdc++
编译命令
# 进入sample所在目录:
cd /app/communication_demo/hbmem_demo/sample_hbmem
# 编译本sample:
make
# 输出文件:
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample
运行
支持平台
- RDK S100/RDK S100P
运行指南
运行方法
创建com buffer
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 1
创建cache,noncached com buffer,赋值,比较耗时
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 2
在各个heaps里,创建com buffer
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 3
创建graph buffer
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 4
在各个heaps里,创建graph buffer
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 5
创建graph buffer group
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 6
在各个heaps里,创建graph buffer group
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 7
进程内common buffer共享
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 8
进程内common buffer共享,consume_cnt
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 9
进程间common buffer共享
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 10
进程内graphic buffer共享
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 11
进程内graphic buffer共享,consume_cnt
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 12
进程间graphic buffer共享
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 13
进程内graphic buffer group共享
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 14
进程内graphic buffer group共享,consume_cnt
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 15
进程间graphic buffer group共享
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 16
进程间share pool 共享
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 17
share pool使用
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 18
buffer queue 使用
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 19
pool使用
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 20
在graphic buffer与common buffer之间实现buffer转换
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 21
增加common buffer用户态引用计数
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 22
增加graphic buffer用户态引用计数
/app/communication_demo/hbmem_demo/sample_hbmem/libhbmem_sample -m 23
运行参数说明
-m
指定sample用例,具体见运行结果展示
测试结果说明
- 如果log最后以
xxxx done
结尾,则表示sample执行成功