mirror of
https://github.com/espressif/esp-idf
synced 2025-04-01 20:30:09 -04:00
fix a2dp deinit crash
This commit is contained in:
parent
1e2d7ea792
commit
3ba13749d3
@ -1421,7 +1421,7 @@ static void btc_a2dp_source_handle_timer(UNUSED_ATTR void *context)
|
|||||||
log_tstamps_us("media task tx timer");
|
log_tstamps_us("media task tx timer");
|
||||||
|
|
||||||
#if (BTA_AV_INCLUDED == TRUE)
|
#if (BTA_AV_INCLUDED == TRUE)
|
||||||
if (btc_a2dp_source_state != BTC_A2DP_SOURCE_STATE_ON){
|
if (btc_a2dp_source_state != BTC_A2DP_SOURCE_STATE_ON || g_a2dp_source_ongoing_deinit){
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -48,6 +48,11 @@ bool g_av_with_rc;
|
|||||||
bool g_a2dp_on_init;
|
bool g_a2dp_on_init;
|
||||||
// global variable to indicate a2dp is deinitialized
|
// global variable to indicate a2dp is deinitialized
|
||||||
bool g_a2dp_on_deinit;
|
bool g_a2dp_on_deinit;
|
||||||
|
// global variable to indicate a2dp source deinitialization is ongoing
|
||||||
|
bool g_a2dp_source_ongoing_deinit;
|
||||||
|
// global variable to indicate a2dp sink deinitialization is ongoing
|
||||||
|
bool g_a2dp_sink_ongoing_deinit;
|
||||||
|
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
** Constants & Macros
|
** Constants & Macros
|
||||||
@ -136,6 +141,7 @@ static BOOLEAN btc_av_state_opening_handler(btc_sm_event_t event, void *data);
|
|||||||
static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *data);
|
static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *data);
|
||||||
static BOOLEAN btc_av_state_started_handler(btc_sm_event_t event, void *data);
|
static BOOLEAN btc_av_state_started_handler(btc_sm_event_t event, void *data);
|
||||||
static BOOLEAN btc_av_state_closing_handler(btc_sm_event_t event, void *data);
|
static BOOLEAN btc_av_state_closing_handler(btc_sm_event_t event, void *data);
|
||||||
|
static void clean_up(int service_id);
|
||||||
|
|
||||||
#if BTC_AV_SRC_INCLUDED
|
#if BTC_AV_SRC_INCLUDED
|
||||||
static bt_status_t btc_a2d_src_init(void);
|
static bt_status_t btc_a2d_src_init(void);
|
||||||
@ -704,6 +710,12 @@ static BOOLEAN btc_av_state_opened_handler(btc_sm_event_t event, void *p_data)
|
|||||||
|
|
||||||
/* change state to idle, send acknowledgement if start is pending */
|
/* change state to idle, send acknowledgement if start is pending */
|
||||||
btc_sm_change_state(btc_av_cb.sm_handle, BTC_AV_STATE_IDLE);
|
btc_sm_change_state(btc_av_cb.sm_handle, BTC_AV_STATE_IDLE);
|
||||||
|
|
||||||
|
if (g_a2dp_source_ongoing_deinit) {
|
||||||
|
clean_up(BTA_A2DP_SOURCE_SERVICE_ID);
|
||||||
|
} else if (g_a2dp_sink_ongoing_deinit) {
|
||||||
|
clean_up(BTA_A2DP_SINK_SERVICE_ID);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -892,6 +904,12 @@ static BOOLEAN btc_av_state_started_handler(btc_sm_event_t event, void *p_data)
|
|||||||
btc_report_connection_state(ESP_A2D_CONNECTION_STATE_DISCONNECTED, &(btc_av_cb.peer_bda),
|
btc_report_connection_state(ESP_A2D_CONNECTION_STATE_DISCONNECTED, &(btc_av_cb.peer_bda),
|
||||||
close->disc_rsn);
|
close->disc_rsn);
|
||||||
btc_sm_change_state(btc_av_cb.sm_handle, BTC_AV_STATE_IDLE);
|
btc_sm_change_state(btc_av_cb.sm_handle, BTC_AV_STATE_IDLE);
|
||||||
|
|
||||||
|
if (g_a2dp_source_ongoing_deinit) {
|
||||||
|
clean_up(BTA_A2DP_SOURCE_SERVICE_ID);
|
||||||
|
} else if (g_a2dp_sink_ongoing_deinit) {
|
||||||
|
clean_up(BTA_A2DP_SINK_SERVICE_ID);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
CHECK_RC_EVENT(event, p_data);
|
CHECK_RC_EVENT(event, p_data);
|
||||||
@ -1014,6 +1032,8 @@ static bt_status_t btc_av_init(int service_id)
|
|||||||
#endif
|
#endif
|
||||||
g_a2dp_on_init = false;
|
g_a2dp_on_init = false;
|
||||||
g_a2dp_on_deinit = true;
|
g_a2dp_on_deinit = true;
|
||||||
|
g_a2dp_source_ongoing_deinit = false;
|
||||||
|
g_a2dp_sink_ongoing_deinit = false;
|
||||||
goto av_init_fail;
|
goto av_init_fail;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1030,6 +1050,8 @@ static bt_status_t btc_av_init(int service_id)
|
|||||||
btc_a2dp_on_init();
|
btc_a2dp_on_init();
|
||||||
g_a2dp_on_init = true;
|
g_a2dp_on_init = true;
|
||||||
g_a2dp_on_deinit = false;
|
g_a2dp_on_deinit = false;
|
||||||
|
g_a2dp_source_ongoing_deinit = false;
|
||||||
|
g_a2dp_sink_ongoing_deinit = false;
|
||||||
|
|
||||||
esp_a2d_cb_param_t param;
|
esp_a2d_cb_param_t param;
|
||||||
memset(¶m, 0, sizeof(esp_a2d_cb_param_t));
|
memset(¶m, 0, sizeof(esp_a2d_cb_param_t));
|
||||||
@ -1105,6 +1127,8 @@ static void clean_up(int service_id)
|
|||||||
#endif
|
#endif
|
||||||
g_a2dp_on_init = false;
|
g_a2dp_on_init = false;
|
||||||
g_a2dp_on_deinit = true;
|
g_a2dp_on_deinit = true;
|
||||||
|
g_a2dp_source_ongoing_deinit = false;
|
||||||
|
g_a2dp_sink_ongoing_deinit = false;
|
||||||
|
|
||||||
esp_a2d_cb_param_t param;
|
esp_a2d_cb_param_t param;
|
||||||
memset(¶m, 0, sizeof(esp_a2d_cb_param_t));
|
memset(¶m, 0, sizeof(esp_a2d_cb_param_t));
|
||||||
@ -1538,7 +1562,15 @@ static bt_status_t btc_a2d_sink_connect(bt_bdaddr_t *remote_bda)
|
|||||||
|
|
||||||
static void btc_a2d_sink_deinit(void)
|
static void btc_a2d_sink_deinit(void)
|
||||||
{
|
{
|
||||||
clean_up(BTA_A2DP_SINK_SERVICE_ID);
|
g_a2dp_sink_ongoing_deinit = true;
|
||||||
|
if (btc_av_is_connected()) {
|
||||||
|
BTA_AvClose(btc_av_cb.bta_handle);
|
||||||
|
if (btc_av_cb.peer_sep == AVDT_TSEP_SRC && g_av_with_rc == true) {
|
||||||
|
BTA_AvCloseRc(btc_av_cb.bta_handle);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
clean_up(BTA_A2DP_SINK_SERVICE_ID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* BTC_AV_SINK_INCLUDED */
|
#endif /* BTC_AV_SINK_INCLUDED */
|
||||||
@ -1563,7 +1595,15 @@ static bt_status_t btc_a2d_src_init(void)
|
|||||||
|
|
||||||
static void btc_a2d_src_deinit(void)
|
static void btc_a2d_src_deinit(void)
|
||||||
{
|
{
|
||||||
clean_up(BTA_A2DP_SOURCE_SERVICE_ID);
|
g_a2dp_source_ongoing_deinit = true;
|
||||||
|
if (btc_av_is_connected()) {
|
||||||
|
BTA_AvClose(btc_av_cb.bta_handle);
|
||||||
|
if (btc_av_cb.peer_sep == AVDT_TSEP_SNK && g_av_with_rc == true) {
|
||||||
|
BTA_AvCloseRc(btc_av_cb.bta_handle);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
clean_up(BTA_A2DP_SOURCE_SERVICE_ID);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static bt_status_t btc_a2d_src_connect(bt_bdaddr_t *remote_bda)
|
static bt_status_t btc_a2d_src_connect(bt_bdaddr_t *remote_bda)
|
||||||
|
@ -40,6 +40,11 @@ extern bool g_av_with_rc;
|
|||||||
extern bool g_a2dp_on_init;
|
extern bool g_a2dp_on_init;
|
||||||
// global variable to indicate a2dp is deinitialized
|
// global variable to indicate a2dp is deinitialized
|
||||||
extern bool g_a2dp_on_deinit;
|
extern bool g_a2dp_on_deinit;
|
||||||
|
// global variable to indicate a2dp source deinitialization is ongoing
|
||||||
|
extern bool g_a2dp_source_ongoing_deinit;
|
||||||
|
// global variable to indicate a2dp sink deinitialization is ongoing
|
||||||
|
extern bool g_a2dp_sink_ongoing_deinit;
|
||||||
|
|
||||||
/*******************************************************************************
|
/*******************************************************************************
|
||||||
** Type definitions for callback functions
|
** Type definitions for callback functions
|
||||||
********************************************************************************/
|
********************************************************************************/
|
||||||
|
Loading…
x
Reference in New Issue
Block a user