【瑞昱RTL8763E】音频

1 音乐播放控制

1.1 播放列表更新

文件系统在sd卡中保存header.bin及name.bin两份文件用于歌曲名称的存储。为方便应用层进行歌曲显示及列表管理,可将这两个bin文件信息读取并保存到nor flash中。需要播放指定名称的歌曲时,将对于歌曲名称传递给文件系统接口,可直接完成歌曲的播放。

uint32_t audio_fs_get_header_list_size(void);

uint32_t audio_fs_get_name_list_size(void);

uint16_t audio_fs_read_header_list(uint32_t offset, uint8_t *readBuf, uint32_t readLen, uint32_t *len);

uint16_t audio_fs_read_name_list(uint32_t offset, uint8_t *readBuf, uint32_t readLen, uint32_t *len);

  • offset,文件偏移地址
  • readBuf,读取数据buffer
  • readLen,期望读取长度
  • len,实际读取长度

header.bin描述歌曲总数及各个歌曲名称在name.bin中的偏移及长度信息。header.bin格式如下。

|--------|----------|--------------------------|--------------------------|--------|
| Count | Reserved | Song info1 | Song info2 | ...... |
| 2bytes | 4bytes | Sizeof(T_SONG_NAME_INFO) | Sizeof(T_SONG_NAME_INFO) | |

typedef struct

{

uint32_t offset; //Start offset of the song name

uint16_t length; //Length of the song name

uint16_t plIndex; /*Play List Index, indicate which playlist the song belongs to.

uint8_t isDeleted : 1; /* flag of if song is deleted.1: deleted,0: not deleted */

uint8_t needToUnlink : 1; /* flag of if song need to unlink. */

uint8_t extension : 6;

uint16_t rsv; /* Reserve for future usage, should set to "0" */

} attribute((packed)) T_SONG_NAME_INFO;

name.bin保存各个歌曲的名称信息,结合song info中提供的offset和length部分,可以提取到各个歌曲的名称。

|--------------------|--------------------|--------|
| Song name 1 | Song name 2 | ...... |
| Name data(Unicode) | Name data(Unicode) | |

1.2音乐播放控制

T_APP_AUDIO_FS_ERROR app_audio_fs_interface_play_by_name(uint8_t *file_name, uint16_t length)

void app_mmi_handle_action(uint8_t action)

case IO_MSG_MMI:

{

uint8_t action = p_watch_msg->u.param;

app_mmi_handle_action(action);

}

break;

case IO_MSG_PLAY_BY_NAME:

{

if (app_db.usb_status == USB_PLUG_OUT)

{

T_SONG_NAME_INFO *play_name = (T_SONG_NAME_INFO *)p_watch_msg->u.param;

app_audio_fs_interface_play_by_name((uint8_t *)(MUSIC_NAME_BIN_ADDR + play_name->offset), play_name->length);

}

else

{

APP_PRINT_INFO0("ERROR: USB plug in, disallow play media now!");

}

}

break;

音频控制,包括播放、暂停、音量调节等,可通过MMI(Man Machine Interface)和app_audio_fs_interface_play_by_name完成。播放列表的维护由上层进行,切换歌曲时,上层只需要控制传入歌曲的名称信息即可。MMI命令所定义的action可参考T_MMI_ACTION,已实现的功能参考void app_mmi_handle_action(uint8_t action)。

本地播放模式与耳机播放模式下,上层共用MMI命令,底下会做区分。不同模式之间的切换也可通过MMI命令完成。

相关推荐
敲敲敲敲暴你脑袋11 小时前
写个添加注释的vscode插件
javascript·typescript·visual studio code
golang学习记12 小时前
GitLens 十大神技:彻底改变你在 VS Code 中的 Git 工作流
前端·后端·visual studio code
小兵张健2 天前
为什么我放弃了 JetBrains 系列,转向 VSCode 等衍生物
visual studio code·jetbrains
晚风予星2 天前
Ant Design Token Lens 迎来了全面升级!支持在 .tsx 或 .ts 文件中直接使用 Design Token
前端·react.js·visual studio code
埃博拉酱3 天前
VS Code Remote SSH 连接 Windows 服务器卡在"下载 VS Code 服务器":prcdn DNS 解析失败的诊断与 BITS 断点续传
windows·ssh·visual studio code
孟陬4 天前
Tanstack Start 的天才创新之处——基于实际使用体验
react.js·visual studio code·next.js
REDcker4 天前
WebCodecs VideoDecoder 的 hardwareAcceleration 使用
前端·音视频·实时音视频·直播·webcodecs·videodecoder
gihigo19984 天前
基于TCP协议实现视频采集与通信
网络协议·tcp/ip·音视频
悠哉悠哉愿意4 天前
【单片机学习笔记】串口、超声波、NE555的同时使用
笔记·单片机·学习
Lester_11014 天前
STM32霍尔传感器输入口设置为复用功能输入口时,还能用GPIO函数直接读取IO的状态吗
stm32·单片机·嵌入式硬件·电机控制