mcu_ab568x/app/platform/bsp/bsp_music.c
2025-05-30 18:03:10 +08:00

102 lines
2.2 KiB
C
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#include "include.h"
#include "app_variable.h"
#define FS_CRC_SEED 0xffff
static uint8_t mp3_res_playing;
uint calc_crc(void *buf, uint len, uint seed);
void mp3_res_play_kick(u32 addr, u32 len);
void wav_res_play_kick(u32 addr, u32 len);
void wav_res_dec_process(void);
bool wav_res_is_play(void);
bool wav_res_stop(void);
void mp3_res_play_exit(void);
static void set_mp3_res_sta(uint8_t sta)
{
mp3_res_playing = sta;
}
uint8_t get_mp3_res_sta(void)
{
return mp3_res_playing;
}
u8 mp3_res_process(void)
{
if (get_mp3_res_sta()) {
if (get_music_dec_sta() == MUSIC_STOP) {
// printf("mp3 ring stop:%d\n", sys_cb.mute);
set_mp3_res_sta(false);
music_control(MUSIC_MSG_STOP);
bsp_change_volume(SysVariable.vol);
if (music_set_eq_is_done()) {
music_set_eq_by_num(sys_cb.eq_mode); // 恢复 EQ
}
mp3_res_play_exit();
if (sys_cb.mute) {
bsp_loudspeaker_mute();
}
#if DAC_DNR_EN
dac_dnr_set_sta(sta);
#endif
func_bt_mp3_play_restore();
return 0;
}
}
return 1;
}
void mp3_res_play_do(u32 addr, u32 len, bool sync)
{
// printf("mp3 ring:%d\n", sys_cb.mute);
if (len == 0) {
return;
}
#if DAC_DNR_EN
u8 sta = dac_dnr_get_sta();
dac_dnr_set_sta(0);
#endif
set_mp3_res_sta(true);
if (sys_cb.mute) {
bsp_loudspeaker_unmute();
}
if (get_music_dec_sta() != MUSIC_STOP) { //避免来电响铃/报号未完成影响get_music_dec_sta()状态
music_control(MUSIC_MSG_STOP);
}
bsp_change_volume(WARNING_VOLUME);
if (music_set_eq_is_done()) {
music_set_eq_by_num(0); // EQ 设置为 normal
}
mp3_res_play_kick(addr, len);
}
void mp3_res_play(u32 addr, u32 len)
{
mp3_res_play_do(addr, len, 0);
}
void mp3_res_play_block(u32 addr, u32 len)
{
bt_audio_bypass();
mp3_res_play(addr, len);
while(mp3_res_process()) {
WDT_CLR();
};
bt_audio_enable();
}