luat_soc_sdk_2024 V1.0
luat_audio_play.h
浏览该文件的文档.
1/*
2 * Copyright (c) 2023 OpenLuat & AirM2M
3 *
4 * Permission is hereby granted, free of charge, to any person obtaining a copy of
5 * this software and associated documentation files (the "Software"), to deal in
6 * the Software without restriction, including without limitation the rights to
7 * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
8 * the Software, and to permit persons to whom the Software is furnished to do so,
9 * subject to the following conditions:
10 *
11 * The above copyright notice and this permission notice shall be included in all
12 * copies or substantial portions of the Software.
13 *
14 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
15 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
16 * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
17 * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
18 * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
19 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
20 */
21
22#ifndef __LUAT_AUDIO_PLAY_EC618_H__
23#define __LUAT_AUDIO_PLAY_EC618_H__
24#include "bsp_common.h"
25#include "common_api.h"
26#include "audio_ll_drv.h"
27#include "audio_play.h"
28#include "luat_audio.h"
29#include "luat_audio_codec.h"
30#include "luat_multimedia.h"
31
39typedef struct
40{
41 char *path;
42 uint32_t address;
43 uint32_t rom_data_len;
44 uint8_t fail_continue;
45 uint8_t dummy[3];
47
50
61 audio_play_event_cb_fun_t event_cb,
62 audio_play_data_cb_fun_t data_cb,
63 audio_play_default_fun_t play_file_fun,
64 audio_play_default_fun_t play_tts_fun,
65 void *user_param);
76void luat_audio_play_global_init_with_task_priority(audio_play_event_cb_fun_t event_cb, audio_play_data_cb_fun_t data_cb, audio_play_default_fun_t play_file_fun, audio_play_default_fun_t play_tts_fun, void *user_param, uint8_t priority);
77#ifndef __LUATOS__
86int luat_audio_play_multi_files(uint8_t multimedia_id, luat_audio_play_info_t info[], uint32_t files_num);
87#endif
94uint8_t luat_audio_play_is_finish(uint8_t multimedia_id);
95
102int luat_audio_play_fast_stop(uint8_t multimedia_id);
109int luat_audio_play_clear_stop_flag(uint8_t multimedia_id);
110
118int luat_audio_play_pause_raw(uint8_t multimedia_id, uint8_t is_pause);
119
126int luat_audio_play_get_last_error(uint8_t multimedia_id);
127
136int luat_audio_play_write_blank_raw(uint8_t multimedia_id, uint8_t cnt, uint8_t add_font);
148int luat_audio_play_start_raw(uint8_t multimedia_id, uint8_t audio_format, uint8_t num_channels, uint32_t sample_rate, uint8_t bits_per_sample, uint8_t is_signed);
157int luat_audio_play_write_raw(uint8_t multimedia_id, uint8_t *data, uint32_t len);
164int luat_audio_play_stop_raw(uint8_t multimedia_id);
165
173void luat_audio_play_tts_set_resource(void *address, void *sdk_id, void *tts_resource_read_fun);
174
181void *luat_audio_play_get_stream(uint8_t multimedia_id);
188void luat_audio_play_set_user_lock(uint8_t multimedia_id, uint8_t onoff);
189void luat_audio_inter_amr_init(uint8_t is_wb, uint8_t quality);
190int luat_audio_inter_amr_encode(const uint16_t *pcm_buf, uint8_t *amr_buf, uint8_t *amr_len);
191int luat_audio_inter_amr_decode(uint16_t *pcm_buf, const uint8_t *amr_buf, uint8_t *amr_len);
195#endif
void luat_audio_inter_amr_deinit(void)
int luat_audio_play_start_raw(uint8_t multimedia_id, uint8_t audio_format, uint8_t num_channels, uint32_t sample_rate, uint8_t bits_per_sample, uint8_t is_signed)
立刻初始化播放未编码的原始音频数据流
void luat_audio_play_global_init(audio_play_event_cb_fun_t event_cb, audio_play_data_cb_fun_t data_cb, audio_play_default_fun_t play_file_fun, audio_play_default_fun_t play_tts_fun, void *user_param)
音频播放初始化,可以选择是否启用TTS,文件播放功能,用来节省flash空间
void luat_audio_play_file_default_fun(void *param)
uint8_t luat_audio_play_is_finish(uint8_t multimedia_id)
是否播放完全部数据
int luat_audio_inter_amr_decode(uint16_t *pcm_buf, const uint8_t *amr_buf, uint8_t *amr_len)
int luat_audio_play_get_last_error(uint8_t multimedia_id)
获取上一次播放结果,在MULTIMEDIA_CB_AUDIO_DONE回调时调用最佳
int luat_audio_play_pause_raw(uint8_t multimedia_id, uint8_t is_pause)
暂停/恢复播放
int luat_audio_play_multi_files(uint8_t multimedia_id, luat_audio_play_info_t info[], uint32_t files_num)
播放指定数量的文件或者ROM数组(文件数据直接写成数组形式)
void luat_audio_play_global_init_with_task_priority(audio_play_event_cb_fun_t event_cb, audio_play_data_cb_fun_t data_cb, audio_play_default_fun_t play_file_fun, audio_play_default_fun_t play_tts_fun, void *user_param, uint8_t priority)
音频播放初始化,可以选择是否启用TTS,文件播放功能,用来节省flash空间,可以配置audio任务优先级
void * luat_audio_play_get_stream(uint8_t multimedia_id)
获取底层播放的stream指针
int luat_audio_play_stop_raw(uint8_t multimedia_id)
强制停止所有播放,同时底层驱动也会停止输出,不要用于播放文件的结束
int luat_audio_inter_amr_encode(const uint16_t *pcm_buf, uint8_t *amr_buf, uint8_t *amr_len)
void luat_audio_play_tts_default_fun(void *param)
void luat_audio_play_tts_set_resource(void *address, void *sdk_id, void *tts_resource_read_fun)
设置TTS的资源和对应SDKID,TTS资源有很多种。
int luat_audio_play_fast_stop(uint8_t multimedia_id)
强制停止播放文件,如果音频解码已经完成了,会停止已经输出到底层驱动的数据播放
int luat_audio_play_clear_stop_flag(uint8_t multimedia_id)
清除强制停止播放文件的标识,可以在误操作stop时不影响下一次播放
void * luat_audio_inter_amr_pcm_address(void)
int luat_audio_play_write_raw(uint8_t multimedia_id, uint8_t *data, uint32_t len)
向底层驱动传入一段原始音频数据
int luat_audio_play_write_blank_raw(uint8_t multimedia_id, uint8_t cnt, uint8_t add_font)
在开头或者结尾插入多段空白数据,每段数据约100ms
void luat_audio_play_set_user_lock(uint8_t multimedia_id, uint8_t onoff)
控制底层播放是否允许结束
void luat_audio_inter_amr_init(uint8_t is_wb, uint8_t quality)
audio播放控制参数