Skip to content

Commit 81579fe

Browse files
author
donglianghao
committed
update 1906 to v1.4
1 parent 17fe17d commit 81579fe

File tree

10 files changed

+98
-55
lines changed

10 files changed

+98
-55
lines changed

components/audio_pipeline/audio_event_iface.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,8 +106,9 @@ static esp_err_t audio_event_iface_cleanup_listener(audio_event_iface_handle_t l
106106
STAILQ_FOREACH_SAFE(item, &listen->listening_queues, next, tmp) {
107107
audio_event_iface_msg_t dummy;
108108
while (audio_event_iface_read(listen, &dummy, 0) == ESP_OK);
109-
if (listen->queue_set && xQueueRemoveFromSet(item->queue, listen->queue_set) != pdPASS) {
109+
while (listen->queue_set && (xQueueRemoveFromSet(item->queue, listen->queue_set) != pdPASS)) {
110110
ESP_LOGW(TAG, "Error remove listener,%p", item->queue);
111+
while (audio_event_iface_read(listen, &dummy, 0) == ESP_OK);
111112
}
112113
}
113114
if (listen->queue_set) {

examples/korvo_du1906/components/audio_player/audio_player.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ audio_err_t audio_player_raw_feed_finish(void)
125125
audio_err_t audio_player_raw_waiting_finished(void)
126126
{
127127
audio_err_t ret = ESP_OK;
128-
ap_ops_t *cur_ops = ap_manager_get_cur_ops();
128+
ap_ops_t *cur_ops = ap_manager_find_ops_by_src(MEDIA_SRC_TYPE_MUSIC_RAW);
129129
if (cur_ops == NULL) {
130130
ESP_LOGW(TAG, "%s, not found the current operations", __func__);
131131
return ESP_ERR_AUDIO_NOT_FOUND_MEDIA_SRC;

examples/korvo_du1906/components/audio_player/audio_player_helper_bt.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,9 +49,7 @@ audio_err_t ap_helper_a2dp_play(ap_ops_attr_t *at, ap_ops_para_t *para)
4949
AUDIO_NULL_CHECK(TAG, a2dp_stream_hd, return ESP_ERR_AUDIO_INVALID_PARAMETER);
5050

5151
int ret = ESP_OK;
52-
#if CONFIG_BT_ENABLED
53-
ret = periph_bt_play((esp_periph_handle_t)para->ctx);
54-
#endif
52+
5553
ret = ap_manager_play(para->url, para->pos, at->blocked, at->auto_resume, at->mixed, at->interrupt, para->media_src);
5654
ESP_LOGI(TAG, "%s, %d", __func__, __LINE__);
5755
return ret;

examples/korvo_du1906/components/audio_player/audio_player_manager.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -681,15 +681,16 @@ audio_err_t ap_manager_play(const char *url, uint32_t pos, bool blocked, bool au
681681
s_player->prepare_playing = false;
682682
return ESP_ERR_AUDIO_MEMORY_LACK;
683683
});
684-
s_player->cur_ops = tmp;
685-
ret = esp_audio_media_type_set(s_player->audio_handle, type);
686684
if (s_player->is_abort_playing) {
687685
s_player->prepare_playing = false;
688686
s_player->is_abort_playing = false;
689687
mutex_unlock(s_player->lock_handle);
690688
ESP_LOGE(TAG, "AP_MANAGER_PLAY exit:%d", __LINE__);
691689
return ESP_ERR_AUDIO_FAIL;
692690
}
691+
692+
s_player->cur_ops = tmp;
693+
ret = esp_audio_media_type_set(s_player->audio_handle, type);
693694
if (blocked == true) {
694695
ESP_LOGW(TAG, "AP_MANAGER_PLAY, Blocked playing, %s, type:%x", s_player->cur_ops->para.url, type);
695696
xEventGroupClearBits(s_player->sync_state, EP_TSK_PLAY_SYNC_TONE_BIT | EP_TSK_PLAY_SYNC_ERROR_BIT);
-30.5 KB
Binary file not shown.
16 Bytes
Binary file not shown.

examples/korvo_du1906/main/app_control.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ static esp_err_t input_key_service_cb(periph_service_handle_t handle, periph_ser
9999
switch ((int)evt->data) {
100100
case INPUT_KEY_USER_ID_MUTE:
101101
if (evt->type == INPUT_KEY_SERVICE_ACTION_PRESS) {
102+
app_bt_start();
102103
audio_player_state_get(&st);
103104
if (st.media_src == MEDIA_SRC_TYPE_MUSIC_A2DP) {
104105
if (((int)st.status == AUDIO_STATUS_RUNNING)) {

examples/korvo_du1906/patches/a2dp_stream_du1906.patch

Lines changed: 88 additions & 46 deletions
Original file line numberDiff line numberDiff line change
@@ -1,50 +1,101 @@
11
diff --git a/components/bluetooth_service/a2dp_stream.c b/components/bluetooth_service/a2dp_stream.c
2-
index 06dc1b4b..c1cacea7 100644
2+
index 1d5c1905..1ddc0346 100644
33
--- a/components/bluetooth_service/a2dp_stream.c
44
+++ b/components/bluetooth_service/a2dp_stream.c
5-
@@ -32,9 +32,16 @@
5+
@@ -34,11 +34,20 @@
66
#include "sdkconfig.h"
77

88
#include "a2dp_stream.h"
99
+#include "esp_avrc_api.h"
1010

1111
#if CONFIG_BT_ENABLED
1212

13+
static const char *TAG = "A2DP_STREAM";
14+
1315
+#define APP_RC_CT_TL_GET_CAPS (0)
1416
+#define APP_RC_CT_TL_GET_META_DATA (1)
1517
+#define APP_RC_CT_TL_RN_TRACK_CHANGE (2)
1618
+#define APP_RC_CT_TL_RN_PLAYBACK_CHANGE (3)
1719
+#define APP_RC_CT_TL_RN_PLAY_POS_CHANGE (4)
1820
+
19-
static const char *TAG = "A2DP_STREAM";
20-
21-
static audio_element_handle_t a2dp_sink_stream_handle = NULL;
22-
@@ -44,6 +51,7 @@ static esp_periph_handle_t bt_avrc_periph = NULL;
23-
static bool avrcp_conn_state = false;
24-
static audio_stream_type_t a2d_stream_type = 0;
25-
static uint8_t trans_label = 0;
2621
+static esp_avrc_rn_evt_cap_mask_t s_avrc_peer_rn_cap;
22+
+
23+
typedef struct {
24+
audio_element_handle_t sink_stream;
25+
audio_element_handle_t source_stream;
26+
@@ -84,19 +93,19 @@ static void audio_a2dp_stream_thread(void *pvParameters)
2727

28-
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0))
29-
static audio_hal_handle_t audio_hal = NULL;
30-
@@ -219,7 +227,7 @@ audio_element_handle_t a2dp_stream_init(a2dp_stream_config_t *config)
28+
a2dp_data_t recv_msg;
29+
bool _aadp_task_run = true;
30+
- while(_aadp_task_run) {
31+
+ while (_aadp_task_run) {
32+
if ( pdTRUE == xQueueReceive (s_aadp_handler.a2dp_queue, &recv_msg, portMAX_DELAY) ) {
33+
switch (recv_msg.type) {
34+
- case A2DP_TYPE_SINK:
35+
+ case A2DP_TYPE_SINK:
36+
audio_element_output(s_aadp_handler.sink_stream, (char *)recv_msg.data, recv_msg.size);
37+
audio_free(recv_msg.data);
38+
recv_msg.data = NULL;
39+
- break;
40+
- case A2DP_TYPE_DESTORY:
41+
- _aadp_task_run = false;
42+
- break;
43+
- default:
44+
- break;
45+
+ break;
46+
+ case A2DP_TYPE_DESTORY:
47+
+ _aadp_task_run = false;
48+
+ break;
49+
+ default:
50+
+ break;
51+
}
52+
}
53+
}
54+
@@ -194,7 +203,7 @@ static void bt_a2d_sink_data_cb(const uint8_t *data, uint32_t len)
55+
ESP_LOGW(TAG, "discard a2dp(%p) sink pkt, A2DP_STREAM_QUEUE_SIZE value needs to be expanded", s_aadp_handler.a2dp_queue);
56+
audio_free(send_msg.data);
57+
send_msg.data = NULL;
58+
- }
59+
+ }
60+
}
61+
}
62+
}
63+
@@ -288,7 +297,7 @@ audio_element_handle_t a2dp_stream_init(a2dp_stream_config_t *config)
64+
}
3165

3266
cfg.task_stack = -1; // No need task
33-
cfg.tag = "aadp";
34-
-
35-
+
67+
- cfg.tag = "aadp";
68+
+ cfg.tag = "aadp";
69+
3670
esp_avrc_ct_init();
3771
esp_avrc_ct_register_callback(bt_avrc_ct_cb);
72+
@@ -325,7 +334,7 @@ audio_element_handle_t a2dp_stream_init(a2dp_stream_config_t *config)
73+
}
3874

39-
@@ -295,13 +303,63 @@ static void bt_avrc_volume_set_by_local(int16_t volume)
40-
rn_param.volume = g_volume;
75+
AUDIO_MEM_CHECK(TAG, el, return NULL);
76+
-
77+
+
78+
memcpy(&s_aadp_handler.user_callback, &config->user_callback, sizeof(a2dp_stream_user_callback_t));
79+
80+
if ( config->type == AUDIO_STREAM_READER ) {
81+
@@ -335,7 +344,7 @@ audio_element_handle_t a2dp_stream_init(a2dp_stream_config_t *config)
82+
return NULL;
83+
}
84+
esp_err_t err = audio_thread_create(&s_aadp_handler.a2dp_thread, "audio_a2dp_stream_thread", audio_a2dp_stream_thread, NULL,
85+
- A2DP_STREAM_TASK_STACK, A2DP_STREAM_TASK_PRIO, A2DP_STREAM_TASK_IN_EXT, A2DP_STREAM_TASK_CORE);
86+
+ A2DP_STREAM_TASK_STACK, A2DP_STREAM_TASK_PRIO, A2DP_STREAM_TASK_IN_EXT, A2DP_STREAM_TASK_CORE);
87+
if (err != ESP_OK) {
88+
ESP_LOGE(TAG, "Create audio_a2dp_stream_thread failed(%d)", __LINE__);
89+
return NULL;
90+
@@ -378,13 +387,64 @@ static void bt_avrc_volume_set_by_local(int16_t volume)
91+
rn_param.volume = s_aadp_handler.volume;
4192
esp_avrc_tg_send_rn_rsp(ESP_AVRC_RN_VOLUME_CHANGE, ESP_AVRC_RN_RSP_CHANGED, &rn_param);
42-
if (audio_hal) {
43-
- audio_hal_set_volume(audio_hal, g_volume);
93+
if (s_aadp_handler.audio_hal) {
94+
- audio_hal_set_volume(s_aadp_handler.audio_hal, s_aadp_handler.volume);
4495
- }
45-
+ audio_hal_set_volume(audio_hal, g_volume);
96+
+ audio_hal_set_volume(s_aadp_handler.audio_hal, s_aadp_handler.volume);
4697
+ }
47-
g_volume_notify = false;
98+
s_aadp_handler.volume_notify = false;
4899
}
49100
}
50101
#endif
@@ -98,19 +149,18 @@ index 06dc1b4b..c1cacea7 100644
98149
+ break;
99150
+ }
100151
+}
152+
+
101153
+
102154
static void bt_avrc_ct_cb(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t *p_param)
103155
{
104156
esp_avrc_ct_cb_param_t *rc = p_param;
105-
@@ -312,17 +370,21 @@ static void bt_avrc_ct_cb(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t *
157+
@@ -395,17 +455,19 @@ static void bt_avrc_ct_cb(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t *
106158
if (rc->conn_stat.connected) {
107159
ESP_LOGD(TAG, "ESP_AVRC_CT_CONNECTION_STATE_EVT");
108160
bt_key_act_sm_init();
109-
+ // get remote supported event_ids of peer AVRCP Target
110161
+ esp_avrc_ct_send_get_rn_capabilities_cmd(APP_RC_CT_TL_GET_CAPS);
111162
} else if (0 == rc->conn_stat.connected) {
112163
bt_key_act_sm_deinit();
113-
+ // clear peer notification capability record
114164
+ s_avrc_peer_rn_cap.bits = 0;
115165
}
116166

@@ -120,24 +170,16 @@ index 06dc1b4b..c1cacea7 100644
120170
break;
121171
}
122172
case ESP_AVRC_CT_PASSTHROUGH_RSP_EVT: {
123-
if (avrcp_conn_state) {
173+
if (s_aadp_handler.avrcp_conn_state) {
124174
- ESP_LOGD(TAG, "AVRC passthrough rsp: key_code 0x%x, key_state %d", rc->psth_rsp.key_code, rc->psth_rsp.key_state);
125175
+ ESP_LOGI(TAG, "AVRC passthrough rsp: key_code 0x%x, key_state %d", rc->psth_rsp.key_code, rc->psth_rsp.key_state);
126176
bt_key_act_param_t param;
127177
memset(&param, 0, sizeof(bt_key_act_param_t));
128178
param.evt = event;
129-
@@ -334,16 +396,26 @@ static void bt_avrc_ct_cb(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t *
130-
break;
131-
}
132-
case ESP_AVRC_CT_METADATA_RSP_EVT: {
133-
- ESP_LOGD(TAG, "AVRC metadata rsp: attribute id 0x%x, %s", rc->meta_rsp.attr_id, rc->meta_rsp.attr_text);
134-
+ ESP_LOGI(TAG, "AVRC metadata rsp: attribute id 0x%x, %s", rc->meta_rsp.attr_id, rc->meta_rsp.attr_text);
135-
// free(rc->meta_rsp.attr_text);
136-
break;
179+
@@ -423,10 +485,20 @@ static void bt_avrc_ct_cb(esp_avrc_ct_cb_event_t event, esp_avrc_ct_cb_param_t *
137180
}
138181
case ESP_AVRC_CT_CHANGE_NOTIFY_EVT: {
139-
- // ESP_LOGD(TAG, "AVRC event notification: %u, param: %u", rc->change_ntf.event_id, rc->change_ntf.event_parameter);
140-
+ // ESP_LOGI(TAG, "AVRC event notification: %u, param: %u", rc->change_ntf.event_id, rc->change_ntf.event_parameter);
182+
// ESP_LOGD(TAG, "AVRC event notification: %u, param: %u", rc->change_ntf.event_id, rc->change_ntf.event_parameter);
141183
+ bt_av_notify_evt_handler(rc->change_ntf.event_id, &rc->change_ntf.event_parameter);
142184
break;
143185
}
@@ -156,15 +198,15 @@ index 06dc1b4b..c1cacea7 100644
156198
break;
157199
}
158200
default:
159-
@@ -358,45 +430,45 @@ static void bt_avrc_tg_cb(esp_avrc_tg_cb_event_t event, esp_avrc_tg_cb_param_t *
201+
@@ -441,45 +513,45 @@ static void bt_avrc_tg_cb(esp_avrc_tg_cb_event_t event, esp_avrc_tg_cb_param_t *
160202
ESP_LOGD(TAG, "%s evt %d", __func__, event);
161203
esp_avrc_tg_cb_param_t *rc = (esp_avrc_tg_cb_param_t *)(param);
162204
switch (event) {
163205
- case ESP_AVRC_TG_CONNECTION_STATE_EVT: {
164206
- uint8_t *bda = rc->conn_stat.remote_bda;
165207
- ESP_LOGI(TAG, "AVRC conn_state evt: state %d, [%02x:%02x:%02x:%02x:%02x:%02x]",
166208
- rc->conn_stat.connected, bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
167-
- avrcp_conn_tg_state = rc->conn_stat.connected;
209+
- s_aadp_handler.avrcp_conn_tg_state = rc->conn_stat.connected;
168210
- break;
169211
- }
170212
- case ESP_AVRC_TG_PASSTHROUGH_CMD_EVT: {
@@ -179,9 +221,9 @@ index 06dc1b4b..c1cacea7 100644
179221
- case ESP_AVRC_TG_REGISTER_NOTIFICATION_EVT: {
180222
- ESP_LOGI(TAG, "AVRC register event notification: %d, param: 0x%x", rc->reg_ntf.event_id, rc->reg_ntf.event_parameter);
181223
- if (rc->reg_ntf.event_id == ESP_AVRC_RN_VOLUME_CHANGE) {
182-
- g_volume_notify = true;
224+
- s_aadp_handler.volume_notify = true;
183225
- esp_avrc_rn_param_t rn_param;
184-
- rn_param.volume = g_volume;
226+
- rn_param.volume = s_aadp_handler.volume;
185227
- esp_avrc_tg_send_rn_rsp(ESP_AVRC_RN_VOLUME_CHANGE, ESP_AVRC_RN_RSP_INTERIM, &rn_param);
186228
- }
187229
- break;
@@ -197,7 +239,7 @@ index 06dc1b4b..c1cacea7 100644
197239
+ uint8_t *bda = rc->conn_stat.remote_bda;
198240
+ ESP_LOGI(TAG, "AVRC conn_state evt: state %d, [%02x:%02x:%02x:%02x:%02x:%02x]",
199241
+ rc->conn_stat.connected, bda[0], bda[1], bda[2], bda[3], bda[4], bda[5]);
200-
+ avrcp_conn_tg_state = rc->conn_stat.connected;
242+
+ s_aadp_handler.avrcp_conn_tg_state = rc->conn_stat.connected;
201243
+ break;
202244
+ }
203245
+ case ESP_AVRC_TG_PASSTHROUGH_CMD_EVT: {
@@ -212,9 +254,9 @@ index 06dc1b4b..c1cacea7 100644
212254
+ case ESP_AVRC_TG_REGISTER_NOTIFICATION_EVT: {
213255
+ ESP_LOGI(TAG, "AVRC register event notification: %d, param: 0x%x", rc->reg_ntf.event_id, rc->reg_ntf.event_parameter);
214256
+ if (rc->reg_ntf.event_id == ESP_AVRC_RN_VOLUME_CHANGE) {
215-
+ g_volume_notify = true;
257+
+ s_aadp_handler.volume_notify = true;
216258
+ esp_avrc_rn_param_t rn_param;
217-
+ rn_param.volume = g_volume;
259+
+ rn_param.volume = s_aadp_handler.volume;
218260
+ esp_avrc_tg_send_rn_rsp(ESP_AVRC_RN_VOLUME_CHANGE, ESP_AVRC_RN_RSP_INTERIM, &rn_param);
219261
+ }
220262
+ break;
@@ -236,12 +278,12 @@ index 06dc1b4b..c1cacea7 100644
236278
return ESP_OK;
237279
}
238280

239-
@@ -428,7 +500,7 @@ static esp_err_t periph_bt_avrc_passthrough_cmd(esp_periph_handle_t periph, uint
281+
@@ -511,7 +583,7 @@ static esp_err_t periph_bt_avrc_passthrough_cmd(esp_periph_handle_t periph, uint
240282
esp_err_t err = ESP_OK;
241283

242284
#if (ESP_IDF_VERSION >= ESP_IDF_VERSION_VAL(4, 0, 0))
243-
- if(avrcp_conn_tg_state) {
244-
+ if (avrcp_conn_tg_state) {
285+
- if(s_aadp_handler.avrcp_conn_tg_state) {
286+
+ if (s_aadp_handler.avrcp_conn_tg_state) {
245287
if (cmd == ESP_AVRC_PT_CMD_VOL_DOWN) {
246-
int16_t volume = (g_volume - 5) < 0 ? 0 : (g_volume - 5);
288+
int16_t volume = (s_aadp_handler.volume - 5) < 0 ? 0 : (s_aadp_handler.volume - 5);
247289
bt_avrc_volume_set_by_local(volume);

examples/korvo_du1906/sdkconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,7 @@ CONFIG_INT_WDT_TIMEOUT_MS=1000
494494
CONFIG_INT_WDT_CHECK_CPU1=y
495495
CONFIG_TASK_WDT=y
496496
CONFIG_TASK_WDT_PANIC=y
497-
CONFIG_TASK_WDT_TIMEOUT_S=12
497+
CONFIG_TASK_WDT_TIMEOUT_S=60
498498
CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y
499499
CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1=y
500500
CONFIG_BROWNOUT_DET=y

examples/korvo_du1906/version.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
v1.3.0
1+
v1.4.0

0 commit comments

Comments
 (0)