File tree 2 files changed +18
-2
lines changed 2 files changed +18
-2
lines changed Original file line number Diff line number Diff line change @@ -84,8 +84,13 @@ void BluetoothA2DPCommon::end(bool release_memory) {
84
84
85
85
// Disconnect and wait
86
86
disconnect ();
87
+ int limit = A2DP_DISCONNECT_LIMIT;
87
88
while (get_connection_state () != ESP_A2D_CONNECTION_STATE_DISCONNECTED){
88
89
delay_ms (100 );
90
+ if (limit-- < 0 ) {
91
+ ESP_LOGW (BT_AV_TAG," Waiting for Disconnect has timed out" );
92
+ break ;
93
+ };
89
94
}
90
95
91
96
// deinit AVRC
@@ -118,8 +123,14 @@ void BluetoothA2DPCommon::end(bool release_memory) {
118
123
log_free_heap ();
119
124
120
125
// waiting for status change
121
- while (esp_bt_controller_get_status () == ESP_BT_CONTROLLER_STATUS_ENABLED)
122
- delay_ms (50 );
126
+ limit = A2DP_DISCONNECT_LIMIT;
127
+ while (esp_bt_controller_get_status () == ESP_BT_CONTROLLER_STATUS_ENABLED){
128
+ delay_ms (100 );
129
+ if (limit-- < 0 ) {
130
+ ESP_LOGW (BT_AV_TAG," Waiting for Enabled has timed out" );
131
+ break ;
132
+ };
133
+ }
123
134
124
135
if (esp_bt_controller_get_status () == ESP_BT_CONTROLLER_STATUS_INITED){
125
136
ESP_LOGI (BT_AV_TAG," esp_bt_controller_deinit" );
Original file line number Diff line number Diff line change 24
24
#ifndef A2DP_I2S_MAX_WRITE_SIZE
25
25
# define A2DP_I2S_MAX_WRITE_SIZE 1024 * 5
26
26
#endif
27
+
28
+ // Maximum wait time for status change in 100 ms when calling end()
29
+ #ifndef A2DP_DISCONNECT_LIMIT
30
+ # define A2DP_DISCONNECT_LIMIT 20
31
+ #endif
You can’t perform that action at this time.
0 commit comments