阿米诺是闪灯

This commit is contained in:
dianke3yu 2025-05-10 22:19:29 +08:00
parent 86f07ca46a
commit 7c930d3481

146
bk_aidk/bk_avdk/components/multimedia/aud/aud_tras_drv.c Executable file → Normal file
View File

@ -58,6 +58,9 @@
#include "psram_mem_slab.h" #include "psram_mem_slab.h"
#include "spi_led.h"
#if CONFIG_AUD_INTF_SUPPORT_PROMPT_TONE #if CONFIG_AUD_INTF_SUPPORT_PROMPT_TONE
#if CONFIG_PROMPT_TONE_SOURCE_ARRAY #if CONFIG_PROMPT_TONE_SOURCE_ARRAY
#include "prompt_tone.h" #include "prompt_tone.h"
@ -3682,6 +3685,10 @@ static bk_err_t aud_tras_drv_prompt_tone_play_open(url_info_t *prompt_tone)
//TODO //TODO
#endif #endif
#if CONFIG_PROMPT_TONE_CODEC_WAV #if CONFIG_PROMPT_TONE_CODEC_WAV
bk_printf("CONFIG_PROMPT_TONE_CODEC_WAV555\n");
//prompt_tone_play_cfg_t config = DEFAULT_VFS_PCM_PROMPT_TONE_PLAY_CONFIG();
prompt_tone_play_cfg_t config = DEFAULT_ARRAY_WAV_PROMPT_TONE_PLAY_CONFIG();
//TODO //TODO
#endif #endif
#if CONFIG_PROMPT_TONE_CODEC_PCM #if CONFIG_PROMPT_TONE_CODEC_PCM
@ -3693,24 +3700,90 @@ static bk_err_t aud_tras_drv_prompt_tone_play_open(url_info_t *prompt_tone)
{ {
config.source_cfg.url = (char *)prompt_tone->url; config.source_cfg.url = (char *)prompt_tone->url;
config.source_cfg.total_size = prompt_tone->total_len; config.source_cfg.total_size = prompt_tone->total_len;
bk_printf("[%s] Prompt tone URL: %s, Size: %lu bytes\n", __func__,
config.source_cfg.url, config.source_cfg.total_size);
}
else
{
bk_printf("[%s] WARNING: prompt_tone parameter is NULL\n", __func__);
} }
/* stop play */ /* Stop previous playback */
if (gl_prompt_tone_play_handle) if (gl_prompt_tone_play_handle)
{ {
bk_printf("[%s] Destroying existing prompt tone handle\n", __func__);
prompt_tone_play_destroy(gl_prompt_tone_play_handle); prompt_tone_play_destroy(gl_prompt_tone_play_handle);
gl_prompt_tone_play_handle = NULL; gl_prompt_tone_play_handle = NULL;
} }
bk_printf("[%s] Creating prompt tone playback handle\n", __func__);
gl_prompt_tone_play_handle = prompt_tone_play_create(&config); gl_prompt_tone_play_handle = prompt_tone_play_create(&config);
if (!gl_prompt_tone_play_handle) if (!gl_prompt_tone_play_handle)
{ {
LOGE("%s, %d, prompt_tone_play_create fail\n", __func__, __LINE__); LOGE("%s, %d, prompt_tone_play_create fail\n", __func__, __LINE__);
bk_printf("[%s] ERROR: Failed to create prompt tone playback handle\n", __func__);
return BK_FAIL; return BK_FAIL;
} }
bk_printf("[%s] Successfully created prompt tone playback handle\n", __func__);
bk_printf("[%s] Opening prompt tone playback\n", __func__);
prompt_tone_play_open(gl_prompt_tone_play_handle); prompt_tone_play_open(gl_prompt_tone_play_handle);
bk_printf("[%s] Prompt tone playback opened successfully\n", __func__);
return BK_OK; return BK_OK;
} }
// static bk_err_t aud_tras_drv_prompt_tone_play_open(url_info_t *prompt_tone)
// {
// LOGI("%s\n", __func__);
// #if CONFIG_PROMPT_TONE_SOURCE_VFS
// #if CONFIG_PROMPT_TONE_CODEC_MP3
// prompt_tone_play_cfg_t config = DEFAULT_VFS_MP3_PROMPT_TONE_PLAY_CONFIG();
// #endif
// #if CONFIG_PROMPT_TONE_CODEC_WAV
// prompt_tone_play_cfg_t config = DEFAULT_VFS_WAV_PROMPT_TONE_PLAY_CONFIG();
// #endif
// #if CONFIG_PROMPT_TONE_CODEC_PCM
// prompt_tone_play_cfg_t config = DEFAULT_VFS_PCM_PROMPT_TONE_PLAY_CONFIG();
// #endif
// #else //array
// #if CONFIG_PROMPT_TONE_CODEC_MP3
// //TODO
// #endif
// #if CONFIG_PROMPT_TONE_CODEC_WAV
// bk_printf("CONFIG_PROMPT_TONE_CODEC_WAV555\n");
// //prompt_tone_play_cfg_t config = DEFAULT_VFS_PCM_PROMPT_TONE_PLAY_CONFIG();
// prompt_tone_play_cfg_t config = DEFAULT_ARRAY_WAV_PROMPT_TONE_PLAY_CONFIG();
// //TODO
// #endif
// #if CONFIG_PROMPT_TONE_CODEC_PCM
// prompt_tone_play_cfg_t config = DEFAULT_ARRAY_PCM_PROMPT_TONE_PLAY_CONFIG();
// #endif
// #endif
// if (prompt_tone)
// {
// config.source_cfg.url = (char *)prompt_tone->url;
// config.source_cfg.total_size = prompt_tone->total_len;
// }
// /* stop play */
// if (gl_prompt_tone_play_handle)
// {
// prompt_tone_play_destroy(gl_prompt_tone_play_handle);
// gl_prompt_tone_play_handle = NULL;
// }
// gl_prompt_tone_play_handle = prompt_tone_play_create(&config);
// if (!gl_prompt_tone_play_handle)
// {
// LOGE("%s, %d, prompt_tone_play_create fail\n", __func__, __LINE__);
// return BK_FAIL;
// }
// prompt_tone_play_open(gl_prompt_tone_play_handle);
// return BK_OK;
// }
static bk_err_t aud_tras_drv_prompt_tone_play_close(void) static bk_err_t aud_tras_drv_prompt_tone_play_close(void)
{ {
@ -5331,18 +5404,22 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_
switch (prompt_tone) switch (prompt_tone)
{ {
case AUD_INTF_VOC_ASR_WAKEUP: case AUD_INTF_VOC_ASR_WAKEUP:
bk_printf("AUD_INTF_VOC_ASR_WAKEUP\n");
LOGI("[prompt_tone] ASR_WAKEUP\n"); LOGI("[prompt_tone] ASR_WAKEUP\n");
#if CONFIG_PROMPT_TONE_SOURCE_VFS #if CONFIG_PROMPT_TONE_SOURCE_VFS
prompt_tone_info.url = asr_wakeup_prompt_tone_path; prompt_tone_info.url = asr_wakeup_prompt_tone_path;
#endif #endif
#if CONFIG_PROMPT_TONE_SOURCE_ARRAY #if CONFIG_PROMPT_TONE_SOURCE_ARRAY
bk_printf("AUD_INTF_VOC_ASR_WAKEUP_CONFIG_PROMPT_TONE_SOURCE_ARRAY\n");
prompt_tone_info.url = (char *)asr_wakeup_prompt_tone_array; prompt_tone_info.url = (char *)asr_wakeup_prompt_tone_array;
prompt_tone_info.total_len = sizeof(asr_wakeup_prompt_tone_array); prompt_tone_info.total_len = sizeof(asr_wakeup_prompt_tone_array);
bk_printf("prompt_tone_info.url = %s prompt_tone_info.total_len = %d\n",prompt_tone_info.url,prompt_tone_info.total_len);
#endif #endif
break; break;
case AUD_INTF_VOC_ASR_STANDBY: case AUD_INTF_VOC_ASR_STANDBY:
LOGI("[prompt_tone] ASR_STANDBY\n"); bk_printf("[prompt_tone] ASR_STANDBY\n");
#if CONFIG_PROMPT_TONE_SOURCE_VFS #if CONFIG_PROMPT_TONE_SOURCE_VFS
prompt_tone_info.url = asr_standby_prompt_tone_path; prompt_tone_info.url = asr_standby_prompt_tone_path;
#endif #endif
@ -5353,7 +5430,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_
break; break;
case AUD_INTF_VOC_NETWORK_PROVISION: case AUD_INTF_VOC_NETWORK_PROVISION:
LOGI("[prompt_tone] NETWORK_PROVISION\n"); bk_printf("[prompt_tone] NETWORK_PROVISION\n");
#if CONFIG_PROMPT_TONE_SOURCE_VFS #if CONFIG_PROMPT_TONE_SOURCE_VFS
prompt_tone_info.url = network_provision_prompt_tone_path; prompt_tone_info.url = network_provision_prompt_tone_path;
#endif #endif
@ -5364,7 +5441,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_
break; break;
case AUD_INTF_VOC_NETWORK_PROVISION_SUCCESS: case AUD_INTF_VOC_NETWORK_PROVISION_SUCCESS:
LOGI("[prompt_tone] NETWORK_PROVISION_SUCCESS\n"); bk_printf("[prompt_tone] NETWORK_PROVISION_SUCCESS\n");
#if CONFIG_PROMPT_TONE_SOURCE_VFS #if CONFIG_PROMPT_TONE_SOURCE_VFS
prompt_tone_info.url = network_provision_success_prompt_tone_path; prompt_tone_info.url = network_provision_success_prompt_tone_path;
#endif #endif
@ -5375,7 +5452,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_
break; break;
case AUD_INTF_VOC_NETWORK_PROVISION_FAIL: case AUD_INTF_VOC_NETWORK_PROVISION_FAIL:
LOGI("[prompt_tone] NETWORK_PROVISION_FAIL\n"); bk_printf("[prompt_tone] NETWORK_PROVISION_FAIL\n");
#if CONFIG_PROMPT_TONE_SOURCE_VFS #if CONFIG_PROMPT_TONE_SOURCE_VFS
prompt_tone_info.url = network_provision_fail_prompt_tone_path; prompt_tone_info.url = network_provision_fail_prompt_tone_path;
#endif #endif
@ -5386,7 +5463,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_
break; break;
case AUD_INTF_VOC_RECONNECT_NETWORK: case AUD_INTF_VOC_RECONNECT_NETWORK:
LOGI("[prompt_tone] RECONNECT_NETWORK\n"); bk_printf("[prompt_tone] RECONNECT_NETWORK\n");
#if CONFIG_PROMPT_TONE_SOURCE_VFS #if CONFIG_PROMPT_TONE_SOURCE_VFS
prompt_tone_info.url = reconnect_network_prompt_tone_path; prompt_tone_info.url = reconnect_network_prompt_tone_path;
#endif #endif
@ -5397,7 +5474,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_
break; break;
case AUD_INTF_VOC_RECONNECT_NETWORK_SUCCESS: case AUD_INTF_VOC_RECONNECT_NETWORK_SUCCESS:
LOGI("[prompt_tone] RECONNECT_NETWORK_SUCCESS\n"); bk_printf("[prompt_tone] RECONNECT_NETWORK_SUCCESS\n");
#if CONFIG_PROMPT_TONE_SOURCE_VFS #if CONFIG_PROMPT_TONE_SOURCE_VFS
prompt_tone_info.url = reconnect_network_success_prompt_tone_path; prompt_tone_info.url = reconnect_network_success_prompt_tone_path;
#endif #endif
@ -5419,7 +5496,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_
break; break;
case AUD_INTF_VOC_RTC_CONNECTION_LOST: case AUD_INTF_VOC_RTC_CONNECTION_LOST:
LOGI("[prompt_tone] CONNECTION_LOST\n"); bk_printf("[prompt_tone] CONNECTION_LOST\n");
#if CONFIG_PROMPT_TONE_SOURCE_VFS #if CONFIG_PROMPT_TONE_SOURCE_VFS
prompt_tone_info.url = rtc_connection_lost_prompt_tone_path; prompt_tone_info.url = rtc_connection_lost_prompt_tone_path;
#endif #endif
@ -5430,7 +5507,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_
break; break;
case AUD_INTF_VOC_AGENT_JOINED: case AUD_INTF_VOC_AGENT_JOINED:
LOGI("[prompt_tone] AGENT_JOINED\n"); bk_printf("[prompt_tone] AGENT_JOINED\n");
#if CONFIG_PROMPT_TONE_SOURCE_VFS #if CONFIG_PROMPT_TONE_SOURCE_VFS
prompt_tone_info.url = agent_joined_prompt_tone_path; prompt_tone_info.url = agent_joined_prompt_tone_path;
#endif #endif
@ -5441,7 +5518,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_
break; break;
case AUD_INTF_VOC_AGENT_OFFLINE: case AUD_INTF_VOC_AGENT_OFFLINE:
LOGI("[prompt_tone] AGENT_OFFLINE\n"); bk_printf("[prompt_tone] AGENT_OFFLINE\n");
#if CONFIG_PROMPT_TONE_SOURCE_VFS #if CONFIG_PROMPT_TONE_SOURCE_VFS
prompt_tone_info.url = agent_offline_prompt_tone_path; prompt_tone_info.url = agent_offline_prompt_tone_path;
#endif #endif
@ -5452,7 +5529,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_
break; break;
case AUD_INTF_VOC_LOW_VOLTAGE: case AUD_INTF_VOC_LOW_VOLTAGE:
LOGI("[prompt_tone] LOW_VOLTAGE\n"); bk_printf("[prompt_tone] LOW_VOLTAGE\n");
#if CONFIG_PROMPT_TONE_SOURCE_VFS #if CONFIG_PROMPT_TONE_SOURCE_VFS
prompt_tone_info.url = low_voltage_prompt_tone_path; prompt_tone_info.url = low_voltage_prompt_tone_path;
#endif #endif
@ -5463,7 +5540,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_
break; break;
case AUD_INTF_VOC_OTA_UPDATE_SUCCESS: case AUD_INTF_VOC_OTA_UPDATE_SUCCESS:
LOGI("[prompt_tone] OTA_UPDATE_SUCCESS\n"); bk_printf("[prompt_tone] OTA_UPDATE_SUCCESS\n");
#if CONFIG_PROMPT_TONE_SOURCE_VFS #if CONFIG_PROMPT_TONE_SOURCE_VFS
prompt_tone_info.url = ota_update_success_prompt_tone_path; prompt_tone_info.url = ota_update_success_prompt_tone_path;
#endif #endif
@ -5474,7 +5551,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_
break; break;
case AUD_INTF_VOC_OTA_UPDATE_FAIL: case AUD_INTF_VOC_OTA_UPDATE_FAIL:
LOGI("[prompt_tone] OTA_UPDATE_FAIL\n"); bk_printf("[prompt_tone] OTA_UPDATE_FAIL\n");
#if CONFIG_PROMPT_TONE_SOURCE_VFS #if CONFIG_PROMPT_TONE_SOURCE_VFS
prompt_tone_info.url = ota_update_fail_prompt_tone_path; prompt_tone_info.url = ota_update_fail_prompt_tone_path;
#endif #endif
@ -5485,7 +5562,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_
break; break;
case AUD_INTF_VOC_AGENT_START_FAIL: case AUD_INTF_VOC_AGENT_START_FAIL:
LOGI("[prompt_tone] AGENT_START_FAIL\n"); bk_printf("[prompt_tone] AGENT_START_FAIL\n");
#if CONFIG_PROMPT_TONE_SOURCE_VFS #if CONFIG_PROMPT_TONE_SOURCE_VFS
prompt_tone_info.url = agent_start_fail_prompt_tone_path; prompt_tone_info.url = agent_start_fail_prompt_tone_path;
#endif #endif
@ -5496,13 +5573,14 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_
break; break;
default: default:
LOGE("%s, %d, prompt_tone: %d not support fail\n", __func__, __LINE__, prompt_tone); bk_printf("%s, %d, prompt_tone: %d not support fail\n", __func__, __LINE__, prompt_tone);
play_flag = false; play_flag = false;
break; break;
} }
if (play_flag) if (play_flag)
{ {
bk_printf("aud_tras_drv_send_msgY\n");
ret = aud_tras_drv_send_msg(AUD_TRAS_PLAY_PROMPT_TONE, (void *)&prompt_tone_info); ret = aud_tras_drv_send_msg(AUD_TRAS_PLAY_PROMPT_TONE, (void *)&prompt_tone_info);
if (ret != BK_OK) if (ret != BK_OK)
{ {
@ -5822,13 +5900,38 @@ static void aud_tras_drv_main(beken_thread_arg_t param_data)
case AUD_TRAS_PLAY_PROMPT_TONE: case AUD_TRAS_PLAY_PROMPT_TONE:
LOGD("AUD_TRAS_PLAY_PROMPT_TONE\n"); LOGD("AUD_TRAS_PLAY_PROMPT_TONE\n");
AUD_PLAY_PROMPT_TONE_START(); int ret = -1;
prompt_tone_play_stop(gl_prompt_tone_play_handle);
prompt_tone_play_set_url(gl_prompt_tone_play_handle, (url_info_t *)msg.param);
prompt_tone_play_start(gl_prompt_tone_play_handle);
bk_printf("AUD_TRAS_PLAY_PROMPT_TONE\n");
AUD_PLAY_PROMPT_TONE_START();
bk_printf("AUD_TRAS_PLAY_PROMPT_TONE\n");
ret = prompt_tone_play_stop(gl_prompt_tone_play_handle);
if(ret == 0){
bk_printf("prompt_tone_play_stop\n");
}
ret = prompt_tone_play_set_url(gl_prompt_tone_play_handle, (url_info_t *)msg.param);
if(ret == 0){
bk_printf("prompt_tone_play_set_url\n");
}
ret = prompt_tone_play_start(gl_prompt_tone_play_handle);
if(ret == 0){
bk_printf("prompt_tone_play_start\n");
}
AUD_PLAY_PROMPT_TONE_END(); AUD_PLAY_PROMPT_TONE_END();
bk_printf("AUD_PLAY_PROMPT_TONE_END\n");
bk_printf("send_spi_led_msg_FLASH_LED\n");
send_spi_led_msg();
// AUD_PLAY_PROMPT_TONE_START();
// prompt_tone_play_stop(gl_prompt_tone_play_handle);
// prompt_tone_play_set_url(gl_prompt_tone_play_handle, (url_info_t *)msg.param);
// prompt_tone_play_start(gl_prompt_tone_play_handle);
// AUD_PLAY_PROMPT_TONE_END();
break; break;
@ -5845,6 +5948,8 @@ static void aud_tras_drv_main(beken_thread_arg_t param_data)
case AUD_TRAS_PLAY_PROMPT_TONE_REQ: case AUD_TRAS_PLAY_PROMPT_TONE_REQ:
{ {
bk_printf("AUD_TRAS_PLAY_PROMPT_TONE_REQ99999\n");
mailbox_msg = (media_mailbox_msg_t *)msg.param; mailbox_msg = (media_mailbox_msg_t *)msg.param;
ret = aud_tras_drv_play_prompt_tone((aud_intf_voc_prompt_tone_t)mailbox_msg->param); ret = aud_tras_drv_play_prompt_tone((aud_intf_voc_prompt_tone_t)mailbox_msg->param);
msg_send_rsp_to_media_major_mailbox(mailbox_msg, ret, APP_MODULE); msg_send_rsp_to_media_major_mailbox(mailbox_msg, ret, APP_MODULE);
@ -6626,6 +6731,7 @@ bk_err_t audio_event_handle(media_mailbox_msg_t * msg)
#if CONFIG_AUD_INTF_SUPPORT_PROMPT_TONE #if CONFIG_AUD_INTF_SUPPORT_PROMPT_TONE
case EVENT_AUD_VOC_PLAY_PROMPT_TONE_REQ: case EVENT_AUD_VOC_PLAY_PROMPT_TONE_REQ:
bk_printf("EVENT_AUD_VOC_PLAY_PROMPT_TONE_REQ\n");
aud_tras_drv_send_msg(AUD_TRAS_PLAY_PROMPT_TONE_REQ, (void *)msg); aud_tras_drv_send_msg(AUD_TRAS_PLAY_PROMPT_TONE_REQ, (void *)msg);
break; break;