Files
JBao_Magic_Box_FW/apps/usr_app/car_audio_test.c
T

52 lines
1.6 KiB
C

/******************************************************************************
* @file car_audio_test.c
* @brief Car audio hardware test using the SDK key-tone sine path.
*
* Notes:
* - The SDK sine sample rate is 16 kHz; points is the PCM sample count.
* - freq is specified as actual frequency * 512.
* - decay=0 keeps amplitude constant for observing DAC/PA end behavior.
* - The parameter array has static storage because playback is asynchronous.
******************************************************************************/
#include <stdint.h>
#include "system/includes.h"
#include "tone_player.h"
#include "application/audio_dec_app.h"
#include "car_audio_test.h"
#include "app_audio_debug.h"
static uint16_t s_car_audio_restart_guard_ms;
int Car_Audio_Test_Play(void)
{
/* bird.mp3 is packed as a standalone file in the internal resource area. */
int ret;
MAGIC_AUDIO_LOG("鸟叫接口进入:资源=%s,当前播放状态=%d",
SDFILE_RES_ROOT_PATH"bird.mp3", audio_key_tone_is_play());
ret = audio_key_tone_play_name(SDFILE_RES_ROOT_PATH"bird.mp3", 1);
MAGIC_AUDIO_LOG("鸟叫请求返回=%d(0仅表示请求已提交,不代表已经出声)", ret);
return ret;
}
void Car_Audio_Test_Loop(uint16_t dt_ms)
{
if (s_car_audio_restart_guard_ms > dt_ms) {
s_car_audio_restart_guard_ms -= dt_ms;
return;
}
if (audio_key_tone_is_play()) {
return;
}
if (Car_Audio_Test_Play() == 0) {
/*
* 防止播放请求刚入队、SDK 尚未更新播放状态时被重复提交。
*/
s_car_audio_restart_guard_ms = 50;
}
}