From 7c930d348140ec5eae0eeaf1da4226b257613fe1 Mon Sep 17 00:00:00 2001 From: dianke3yu <343528259@qq.com> Date: Sat, 10 May 2025 22:19:29 +0800 Subject: [PATCH] =?UTF-8?q?=E9=98=BF=E7=B1=B3=E8=AF=BA=E6=98=AF=E9=97=AA?= =?UTF-8?q?=E7=81=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../components/multimedia/aud/aud_tras_drv.c | 146 +++++++++++++++--- 1 file changed, 126 insertions(+), 20 deletions(-) mode change 100755 => 100644 bk_aidk/bk_avdk/components/multimedia/aud/aud_tras_drv.c diff --git a/bk_aidk/bk_avdk/components/multimedia/aud/aud_tras_drv.c b/bk_aidk/bk_avdk/components/multimedia/aud/aud_tras_drv.c old mode 100755 new mode 100644 index 0d39ba88..564e9616 --- a/bk_aidk/bk_avdk/components/multimedia/aud/aud_tras_drv.c +++ b/bk_aidk/bk_avdk/components/multimedia/aud/aud_tras_drv.c @@ -58,6 +58,9 @@ #include "psram_mem_slab.h" +#include "spi_led.h" + + #if CONFIG_AUD_INTF_SUPPORT_PROMPT_TONE #if CONFIG_PROMPT_TONE_SOURCE_ARRAY #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 #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 @@ -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.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) { + bk_printf("[%s] Destroying existing prompt tone handle\n", __func__); prompt_tone_play_destroy(gl_prompt_tone_play_handle); 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); if (!gl_prompt_tone_play_handle) { 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; } + 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); + bk_printf("[%s] Prompt tone playback opened successfully\n", __func__); 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) { @@ -5331,18 +5404,22 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_ switch (prompt_tone) { case AUD_INTF_VOC_ASR_WAKEUP: + + bk_printf("AUD_INTF_VOC_ASR_WAKEUP\n"); LOGI("[prompt_tone] ASR_WAKEUP\n"); #if CONFIG_PROMPT_TONE_SOURCE_VFS prompt_tone_info.url = asr_wakeup_prompt_tone_path; #endif #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.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 break; 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 prompt_tone_info.url = asr_standby_prompt_tone_path; #endif @@ -5353,7 +5430,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_ break; 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 prompt_tone_info.url = network_provision_prompt_tone_path; #endif @@ -5364,7 +5441,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_ break; 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 prompt_tone_info.url = network_provision_success_prompt_tone_path; #endif @@ -5375,7 +5452,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_ break; 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 prompt_tone_info.url = network_provision_fail_prompt_tone_path; #endif @@ -5386,7 +5463,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_ break; 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 prompt_tone_info.url = reconnect_network_prompt_tone_path; #endif @@ -5397,7 +5474,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_ break; 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 prompt_tone_info.url = reconnect_network_success_prompt_tone_path; #endif @@ -5419,7 +5496,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_ break; 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 prompt_tone_info.url = rtc_connection_lost_prompt_tone_path; #endif @@ -5430,7 +5507,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_ break; 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 prompt_tone_info.url = agent_joined_prompt_tone_path; #endif @@ -5441,7 +5518,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_ break; 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 prompt_tone_info.url = agent_offline_prompt_tone_path; #endif @@ -5452,7 +5529,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_ break; 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 prompt_tone_info.url = low_voltage_prompt_tone_path; #endif @@ -5463,7 +5540,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_ break; 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 prompt_tone_info.url = ota_update_success_prompt_tone_path; #endif @@ -5474,7 +5551,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_ break; 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 prompt_tone_info.url = ota_update_fail_prompt_tone_path; #endif @@ -5485,7 +5562,7 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_ break; 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 prompt_tone_info.url = agent_start_fail_prompt_tone_path; #endif @@ -5496,13 +5573,14 @@ static bk_err_t aud_tras_drv_play_prompt_tone(aud_intf_voc_prompt_tone_t prompt_ break; 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; break; } 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); 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: LOGD("AUD_TRAS_PLAY_PROMPT_TONE\n"); - 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); + int ret = -1; + 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(); + 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; @@ -5845,6 +5948,8 @@ static void aud_tras_drv_main(beken_thread_arg_t param_data) case AUD_TRAS_PLAY_PROMPT_TONE_REQ: { + + bk_printf("AUD_TRAS_PLAY_PROMPT_TONE_REQ99999\n"); mailbox_msg = (media_mailbox_msg_t *)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); @@ -6626,6 +6731,7 @@ bk_err_t audio_event_handle(media_mailbox_msg_t * msg) #if CONFIG_AUD_INTF_SUPPORT_PROMPT_TONE 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); break;