diff --git a/components/audio_pipeline/audio_event_iface.c b/components/audio_pipeline/audio_event_iface.c index 5ab776c4c..d38c1ff14 100644 --- a/components/audio_pipeline/audio_event_iface.c +++ b/components/audio_pipeline/audio_event_iface.c @@ -106,8 +106,9 @@ static esp_err_t audio_event_iface_cleanup_listener(audio_event_iface_handle_t l STAILQ_FOREACH_SAFE(item, &listen->listening_queues, next, tmp) { audio_event_iface_msg_t dummy; while (audio_event_iface_read(listen, &dummy, 0) == ESP_OK); - if (listen->queue_set && xQueueRemoveFromSet(item->queue, listen->queue_set) != pdPASS) { + while (listen->queue_set && (xQueueRemoveFromSet(item->queue, listen->queue_set) != pdPASS)) { ESP_LOGW(TAG, "Error remove listener,%p", item->queue); + while (audio_event_iface_read(listen, &dummy, 0) == ESP_OK); } } if (listen->queue_set) { diff --git a/examples/korvo_du1906/components/audio_player/audio_player.c b/examples/korvo_du1906/components/audio_player/audio_player.c index 67e2d8547..a4aedaea8 100644 --- a/examples/korvo_du1906/components/audio_player/audio_player.c +++ b/examples/korvo_du1906/components/audio_player/audio_player.c @@ -125,7 +125,7 @@ audio_err_t audio_player_raw_feed_finish(void) audio_err_t audio_player_raw_waiting_finished(void) { audio_err_t ret = ESP_OK; - ap_ops_t *cur_ops = ap_manager_get_cur_ops(); + ap_ops_t *cur_ops = ap_manager_find_ops_by_src(MEDIA_SRC_TYPE_MUSIC_RAW); if (cur_ops == NULL) { ESP_LOGW(TAG, "%s, not found the current operations", __func__); return ESP_ERR_AUDIO_NOT_FOUND_MEDIA_SRC; diff --git a/examples/korvo_du1906/components/audio_player/audio_player_helper_bt.c b/examples/korvo_du1906/components/audio_player/audio_player_helper_bt.c index f74cfe363..8c23b05b7 100644 --- a/examples/korvo_du1906/components/audio_player/audio_player_helper_bt.c +++ b/examples/korvo_du1906/components/audio_player/audio_player_helper_bt.c @@ -49,9 +49,7 @@ audio_err_t ap_helper_a2dp_play(ap_ops_attr_t *at, ap_ops_para_t *para) AUDIO_NULL_CHECK(TAG, a2dp_stream_hd, return ESP_ERR_AUDIO_INVALID_PARAMETER); int ret = ESP_OK; -#if CONFIG_BT_ENABLED - ret = periph_bt_play((esp_periph_handle_t)para->ctx); -#endif + ret = ap_manager_play(para->url, para->pos, at->blocked, at->auto_resume, at->mixed, at->interrupt, para->media_src); ESP_LOGI(TAG, "%s, %d", __func__, __LINE__); return ret; diff --git a/examples/korvo_du1906/components/audio_player/audio_player_manager.c b/examples/korvo_du1906/components/audio_player/audio_player_manager.c index 29d4e2980..2d4e538fa 100644 --- a/examples/korvo_du1906/components/audio_player/audio_player_manager.c +++ b/examples/korvo_du1906/components/audio_player/audio_player_manager.c @@ -681,8 +681,6 @@ audio_err_t ap_manager_play(const char *url, uint32_t pos, bool blocked, bool au s_player->prepare_playing = false; return ESP_ERR_AUDIO_MEMORY_LACK; }); - s_player->cur_ops = tmp; - ret = esp_audio_media_type_set(s_player->audio_handle, type); if (s_player->is_abort_playing) { s_player->prepare_playing = false; s_player->is_abort_playing = false; @@ -690,6 +688,9 @@ audio_err_t ap_manager_play(const char *url, uint32_t pos, bool blocked, bool au ESP_LOGE(TAG, "AP_MANAGER_PLAY exit:%d", __LINE__); return ESP_ERR_AUDIO_FAIL; } + + s_player->cur_ops = tmp; + ret = esp_audio_media_type_set(s_player->audio_handle, type); if (blocked == true) { ESP_LOGW(TAG, "AP_MANAGER_PLAY, Blocked playing, %s, type:%x", s_player->cur_ops->para.url, type); xEventGroupClearBits(s_player->sync_state, EP_TSK_PLAY_SYNC_TONE_BIT | EP_TSK_PLAY_SYNC_ERROR_BIT); diff --git a/examples/korvo_du1906/firmware/app.bin b/examples/korvo_du1906/firmware/app.bin index 4f5efc3a4..71983d212 100644 Binary files a/examples/korvo_du1906/firmware/app.bin and b/examples/korvo_du1906/firmware/app.bin differ diff --git a/examples/korvo_du1906/firmware/bootloader.bin b/examples/korvo_du1906/firmware/bootloader.bin index e98d557d1..430f0fbe9 100644 Binary files a/examples/korvo_du1906/firmware/bootloader.bin and b/examples/korvo_du1906/firmware/bootloader.bin differ diff --git a/examples/korvo_du1906/main/app_control.c b/examples/korvo_du1906/main/app_control.c index 032be9f8a..e9173cedf 100755 --- a/examples/korvo_du1906/main/app_control.c +++ b/examples/korvo_du1906/main/app_control.c @@ -99,6 +99,7 @@ static esp_err_t input_key_service_cb(periph_service_handle_t handle, periph_ser switch ((int)evt->data) { case INPUT_KEY_USER_ID_MUTE: if (evt->type == INPUT_KEY_SERVICE_ACTION_PRESS) { + app_bt_start(); audio_player_state_get(&st); if (st.media_src == MEDIA_SRC_TYPE_MUSIC_A2DP) { if (((int)st.status == AUDIO_STATUS_RUNNING)) { diff --git a/examples/korvo_du1906/patches/a2dp_stream_du1906.patch b/examples/korvo_du1906/patches/a2dp_stream_du1906.patch index 81d6a6fed..5bb73a0ec 100644 --- a/examples/korvo_du1906/patches/a2dp_stream_du1906.patch +++ b/examples/korvo_du1906/patches/a2dp_stream_du1906.patch @@ -1,8 +1,8 @@ diff --git a/components/bluetooth_service/a2dp_stream.c b/components/bluetooth_service/a2dp_stream.c -index 06dc1b4b..c1cacea7 100644 +index 1d5c1905..1ddc0346 100644 --- a/components/bluetooth_service/a2dp_stream.c +++ b/components/bluetooth_service/a2dp_stream.c -@@ -32,9 +32,16 @@ +@@ -34,11 +34,20 @@ #include "sdkconfig.h" #include "a2dp_stream.h" @@ -10,41 +10,92 @@ index 06dc1b4b..c1cacea7 100644 #if CONFIG_BT_ENABLED + static const char *TAG = "A2DP_STREAM"; + +#define APP_RC_CT_TL_GET_CAPS (0) +#define APP_RC_CT_TL_GET_META_DATA (1) +#define APP_RC_CT_TL_RN_TRACK_CHANGE (2) +#define APP_RC_CT_TL_RN_PLAYBACK_CHANGE (3) +#define APP_RC_CT_TL_RN_PLAY_POS_CHANGE (4) + - static const char *TAG = "A2DP_STREAM"; - - static audio_element_handle_t a2dp_sink_stream_handle = NULL; -@@ -44,6 +51,7 @@ static esp_periph_handle_t bt_avrc_periph = NULL; - static bool avrcp_conn_state = false; - static audio_stream_type_t a2d_stream_type = 0; - static uint8_t trans_label = 0; +static esp_avrc_rn_evt_cap_mask_t s_avrc_peer_rn_cap; ++ + typedef struct { + audio_element_handle_t sink_stream; + audio_element_handle_t source_stream; +@@ -84,19 +93,19 @@ static void audio_a2dp_stream_thread(void *pvParameters) - #if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0)) - static audio_hal_handle_t audio_hal = NULL; -@@ -219,7 +227,7 @@ audio_element_handle_t a2dp_stream_init(a2dp_stream_config_t *config) + a2dp_data_t recv_msg; + bool _aadp_task_run = true; +- while(_aadp_task_run) { ++ while (_aadp_task_run) { + if ( pdTRUE == xQueueReceive (s_aadp_handler.a2dp_queue, &recv_msg, portMAX_DELAY) ) { + switch (recv_msg.type) { +- case A2DP_TYPE_SINK: ++ case A2DP_TYPE_SINK: + audio_element_output(s_aadp_handler.sink_stream, (char *)recv_msg.data, recv_msg.size); + audio_free(recv_msg.data); + recv_msg.data = NULL; +- break; +- case A2DP_TYPE_DESTORY: +- _aadp_task_run = false; +- break; +- default: +- break; ++ break; ++ case A2DP_TYPE_DESTORY: ++ _aadp_task_run = false; ++ break; ++ default: ++ break; + } + } + } +@@ -194,7 +203,7 @@ static void bt_a2d_sink_data_cb(const uint8_t *data, uint32_t len) + ESP_LOGW(TAG, "discard a2dp(%p) sink pkt, A2DP_STREAM_QUEUE_SIZE value needs to be expanded", s_aadp_handler.a2dp_queue); + audio_free(send_msg.data); + send_msg.data = NULL; +- } ++ } + } + } + } +@@ -288,7 +297,7 @@ audio_element_handle_t a2dp_stream_init(a2dp_stream_config_t *config) + } cfg.task_stack = -1; // No need task - cfg.tag = "aadp"; -- -+ +- cfg.tag = "aadp"; ++ cfg.tag = "aadp"; + esp_avrc_ct_init(); esp_avrc_ct_register_callback(bt_avrc_ct_cb); +@@ -325,7 +334,7 @@ audio_element_handle_t a2dp_stream_init(a2dp_stream_config_t *config) + } -@@ -295,13 +303,63 @@ static void bt_avrc_volume_set_by_local(int16_t volume) - rn_param.volume = g_volume; + AUDIO_MEM_CHECK(TAG, el, return NULL); +- ++ + memcpy(&s_aadp_handler.user_callback, &config->user_callback, sizeof(a2dp_stream_user_callback_t)); + + if ( config->type == AUDIO_STREAM_READER ) { +@@ -335,7 +344,7 @@ audio_element_handle_t a2dp_stream_init(a2dp_stream_config_t *config) + return NULL; + } + esp_err_t err = audio_thread_create(&s_aadp_handler.a2dp_thread, "audio_a2dp_stream_thread", audio_a2dp_stream_thread, NULL, +- A2DP_STREAM_TASK_STACK, A2DP_STREAM_TASK_PRIO, A2DP_STREAM_TASK_IN_EXT, A2DP_STREAM_TASK_CORE); ++ A2DP_STREAM_TASK_STACK, A2DP_STREAM_TASK_PRIO, A2DP_STREAM_TASK_IN_EXT, A2DP_STREAM_TASK_CORE); + if (err != ESP_OK) { + ESP_LOGE(TAG, "Create audio_a2dp_stream_thread failed(%d)", __LINE__); + return NULL; +@@ -378,13 +387,64 @@ static void bt_avrc_volume_set_by_local(int16_t volume) + rn_param.volume = s_aadp_handler.volume; esp_avrc_tg_send_rn_rsp(ESP_AVRC_RN_VOLUME_CHANGE, ESP_AVRC_RN_RSP_CHANGED, &rn_param); - if (audio_hal) { -- audio_hal_set_volume(audio_hal, g_volume); + if (s_aadp_handler.audio_hal) { +- audio_hal_set_volume(s_aadp_handler.audio_hal, s_aadp_handler.volume); - } -+ audio_hal_set_volume(audio_hal, g_volume); ++ audio_hal_set_volume(s_aadp_handler.audio_hal, s_aadp_handler.volume); + } - g_volume_notify = false; + s_aadp_handler.volume_notify = false; } } #endif @@ -98,19 +149,18 @@ index 06dc1b4b..c1cacea7 100644 + break; + } +} ++ + static void bt_avrc_ct_cb(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t *p_param) { esp_avrc_ct_cb_param_t *rc = p_param; -@@ -312,17 +370,21 @@ static void bt_avrc_ct_cb(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t * +@@ -395,17 +455,19 @@ static void bt_avrc_ct_cb(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t * if (rc->conn_stat.connected) { ESP_LOGD(TAG, "ESP_AVRC_CT_CONNECTION_STATE_EVT"); bt_key_act_sm_init(); -+ // get remote supported event_ids of peer AVRCP Target + esp_avrc_ct_send_get_rn_capabilities_cmd(APP_RC_CT_TL_GET_CAPS); } else if (0 == rc->conn_stat.connected) { bt_key_act_sm_deinit(); -+ // clear peer notification capability record + s_avrc_peer_rn_cap.bits = 0; } @@ -120,24 +170,16 @@ index 06dc1b4b..c1cacea7 100644 break; } case ESP_AVRC_CT_PASSTHROUGH_RSP_EVT: { - if (avrcp_conn_state) { + if (s_aadp_handler.avrcp_conn_state) { - ESP_LOGD(TAG, "AVRC passthrough rsp: key_code 0x%x, key_state %d", rc->psth_rsp.key_code, rc->psth_rsp.key_state); + ESP_LOGI(TAG, "AVRC passthrough rsp: key_code 0x%x, key_state %d", rc->psth_rsp.key_code, rc->psth_rsp.key_state); bt_key_act_param_t param; memset(¶m, 0, sizeof(bt_key_act_param_t)); param.evt = event; -@@ -334,16 +396,26 @@ static void bt_avrc_ct_cb(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t * - break; - } - case ESP_AVRC_CT_METADATA_RSP_EVT: { -- ESP_LOGD(TAG, "AVRC metadata rsp: attribute id 0x%x, %s", rc->meta_rsp.attr_id, rc->meta_rsp.attr_text); -+ ESP_LOGI(TAG, "AVRC metadata rsp: attribute id 0x%x, %s", rc->meta_rsp.attr_id, rc->meta_rsp.attr_text); - // free(rc->meta_rsp.attr_text); - break; +@@ -423,10 +485,20 @@ static void bt_avrc_ct_cb(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t * } case ESP_AVRC_CT_CHANGE_NOTIFY_EVT: { -- // ESP_LOGD(TAG, "AVRC event notification: %u, param: %u", rc->change_ntf.event_id, rc->change_ntf.event_parameter); -+ // ESP_LOGI(TAG, "AVRC event notification: %u, param: %u", rc->change_ntf.event_id, rc->change_ntf.event_parameter); + // ESP_LOGD(TAG, "AVRC event notification: %u, param: %u", rc->change_ntf.event_id, rc->change_ntf.event_parameter); + bt_av_notify_evt_handler(rc->change_ntf.event_id, &rc->change_ntf.event_parameter); break; } @@ -156,7 +198,7 @@ index 06dc1b4b..c1cacea7 100644 break; } default: -@@ -358,45 +430,45 @@ static void bt_avrc_tg_cb(esp_avrc_tg_cb_event_t event, esp_avrc_tg_cb_param_t * +@@ -441,45 +513,45 @@ static void bt_avrc_tg_cb(esp_avrc_tg_cb_event_t event, esp_avrc_tg_cb_param_t * ESP_LOGD(TAG, "%s evt %d", __func__, event); esp_avrc_tg_cb_param_t *rc = (esp_avrc_tg_cb_param_t *)(param); switch (event) { @@ -164,7 +206,7 @@ index 06dc1b4b..c1cacea7 100644 - uint8_t *bda = rc->conn_stat.remote_bda; - ESP_LOGI(TAG, "AVRC conn_state evt: state %d, [%02x:%02x:%02x:%02x:%02x:%02x]", - rc->conn_stat.connected, bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]); -- avrcp_conn_tg_state = rc->conn_stat.connected; +- s_aadp_handler.avrcp_conn_tg_state = rc->conn_stat.connected; - break; - } - case ESP_AVRC_TG_PASSTHROUGH_CMD_EVT: { @@ -179,9 +221,9 @@ index 06dc1b4b..c1cacea7 100644 - case ESP_AVRC_TG_REGISTER_NOTIFICATION_EVT: { - ESP_LOGI(TAG, "AVRC register event notification: %d, param: 0x%x", rc->reg_ntf.event_id, rc->reg_ntf.event_parameter); - if (rc->reg_ntf.event_id == ESP_AVRC_RN_VOLUME_CHANGE) { -- g_volume_notify = true; +- s_aadp_handler.volume_notify = true; - esp_avrc_rn_param_t rn_param; -- rn_param.volume = g_volume; +- rn_param.volume = s_aadp_handler.volume; - esp_avrc_tg_send_rn_rsp(ESP_AVRC_RN_VOLUME_CHANGE, ESP_AVRC_RN_RSP_INTERIM, &rn_param); - } - break; @@ -197,7 +239,7 @@ index 06dc1b4b..c1cacea7 100644 + uint8_t *bda = rc->conn_stat.remote_bda; + ESP_LOGI(TAG, "AVRC conn_state evt: state %d, [%02x:%02x:%02x:%02x:%02x:%02x]", + rc->conn_stat.connected, bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]); -+ avrcp_conn_tg_state = rc->conn_stat.connected; ++ s_aadp_handler.avrcp_conn_tg_state = rc->conn_stat.connected; + break; + } + case ESP_AVRC_TG_PASSTHROUGH_CMD_EVT: { @@ -212,9 +254,9 @@ index 06dc1b4b..c1cacea7 100644 + case ESP_AVRC_TG_REGISTER_NOTIFICATION_EVT: { + ESP_LOGI(TAG, "AVRC register event notification: %d, param: 0x%x", rc->reg_ntf.event_id, rc->reg_ntf.event_parameter); + if (rc->reg_ntf.event_id == ESP_AVRC_RN_VOLUME_CHANGE) { -+ g_volume_notify = true; ++ s_aadp_handler.volume_notify = true; + esp_avrc_rn_param_t rn_param; -+ rn_param.volume = g_volume; ++ rn_param.volume = s_aadp_handler.volume; + esp_avrc_tg_send_rn_rsp(ESP_AVRC_RN_VOLUME_CHANGE, ESP_AVRC_RN_RSP_INTERIM, &rn_param); + } + break; @@ -236,12 +278,12 @@ index 06dc1b4b..c1cacea7 100644 return ESP_OK; } -@@ -428,7 +500,7 @@ static esp_err_t periph_bt_avrc_passthrough_cmd(esp_periph_handle_t periph, uint +@@ -511,7 +583,7 @@ static esp_err_t periph_bt_avrc_passthrough_cmd(esp_periph_handle_t periph, uint esp_err_t err = ESP_OK; #if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0)) -- if(avrcp_conn_tg_state) { -+ if (avrcp_conn_tg_state) { +- if(s_aadp_handler.avrcp_conn_tg_state) { ++ if (s_aadp_handler.avrcp_conn_tg_state) { if (cmd == ESP_AVRC_PT_CMD_VOL_DOWN) { - int16_t volume = (g_volume - 5) < 0 ? 0 : (g_volume - 5); + int16_t volume = (s_aadp_handler.volume - 5) < 0 ? 0 : (s_aadp_handler.volume - 5); bt_avrc_volume_set_by_local(volume); diff --git a/examples/korvo_du1906/sdkconfig b/examples/korvo_du1906/sdkconfig index 13b7111ee..2723b6a20 100644 --- a/examples/korvo_du1906/sdkconfig +++ b/examples/korvo_du1906/sdkconfig @@ -494,7 +494,7 @@ CONFIG_INT_WDT_TIMEOUT_MS=1000 CONFIG_INT_WDT_CHECK_CPU1=y CONFIG_TASK_WDT=y CONFIG_TASK_WDT_PANIC=y -CONFIG_TASK_WDT_TIMEOUT_S=12 +CONFIG_TASK_WDT_TIMEOUT_S=60 CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1=y CONFIG_BROWNOUT_DET=y diff --git a/examples/korvo_du1906/version.txt b/examples/korvo_du1906/version.txt index 18fa8e74f..0d0c52f84 100644 --- a/examples/korvo_du1906/version.txt +++ b/examples/korvo_du1906/version.txt @@ -1 +1 @@ -v1.3.0 +v1.4.0