Not initialized or in the process of de-initialization, calling API will return ERR

This commit is contained in:
xiongweichao 2021-07-15 17:59:04 +08:00 committed by bot
parent 55fe021ddb
commit b1bceb6b42

View File

@ -29,6 +29,10 @@ esp_err_t esp_a2d_sink_init(void)
return ESP_ERR_INVALID_STATE;
}
if (g_a2dp_on_init || g_a2dp_sink_ongoing_deinit) {
return ESP_ERR_INVALID_STATE;
}
btc_msg_t msg;
msg.sig = BTC_SIG_API_CALL;
@ -46,6 +50,10 @@ esp_err_t esp_a2d_sink_deinit(void)
return ESP_ERR_INVALID_STATE;
}
if (g_a2dp_on_deinit || g_a2dp_sink_ongoing_deinit) {
return ESP_ERR_INVALID_STATE;
}
btc_msg_t msg;
msg.sig = BTC_SIG_API_CALL;
@ -63,6 +71,10 @@ esp_err_t esp_a2d_sink_register_data_callback(esp_a2d_sink_data_cb_t callback)
return ESP_ERR_INVALID_STATE;
}
if (g_a2dp_sink_ongoing_deinit) {
return ESP_ERR_INVALID_STATE;
}
btc_msg_t msg;
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_A2DP;
@ -83,6 +95,10 @@ esp_err_t esp_a2d_sink_connect(esp_bd_addr_t remote_bda)
return ESP_ERR_INVALID_STATE;
}
if (g_a2dp_on_deinit || g_a2dp_sink_ongoing_deinit) {
return ESP_ERR_INVALID_STATE;
}
bt_status_t stat;
btc_av_args_t arg;
btc_msg_t msg;
@ -105,6 +121,10 @@ esp_err_t esp_a2d_sink_disconnect(esp_bd_addr_t remote_bda)
return ESP_ERR_INVALID_STATE;
}
if (g_a2dp_on_deinit || g_a2dp_sink_ongoing_deinit) {
return ESP_ERR_INVALID_STATE;
}
bt_status_t stat;
btc_av_args_t arg;
btc_msg_t msg;
@ -127,6 +147,10 @@ esp_err_t esp_a2d_register_callback(esp_a2d_cb_t callback)
return ESP_ERR_INVALID_STATE;
}
if (g_a2dp_sink_ongoing_deinit || g_a2dp_source_ongoing_deinit) {
return ESP_ERR_INVALID_STATE;
}
if (callback == NULL) {
return ESP_FAIL;
}
@ -141,6 +165,10 @@ esp_err_t esp_a2d_media_ctrl(esp_a2d_media_ctrl_t ctrl)
return ESP_ERR_INVALID_STATE;
}
if (g_a2dp_on_deinit || g_a2dp_sink_ongoing_deinit || g_a2dp_source_ongoing_deinit) {
return ESP_ERR_INVALID_STATE;
}
bt_status_t stat;
btc_av_args_t arg;
btc_msg_t msg;
@ -164,6 +192,10 @@ esp_err_t esp_a2d_source_init(void)
return ESP_ERR_INVALID_STATE;
}
if (g_a2dp_on_init || g_a2dp_source_ongoing_deinit) {
return ESP_ERR_INVALID_STATE;
}
btc_msg_t msg;
msg.sig = BTC_SIG_API_CALL;
@ -181,6 +213,10 @@ esp_err_t esp_a2d_source_deinit(void)
return ESP_ERR_INVALID_STATE;
}
if (g_a2dp_on_deinit || g_a2dp_source_ongoing_deinit) {
return ESP_ERR_INVALID_STATE;
}
btc_msg_t msg;
msg.sig = BTC_SIG_API_CALL;
@ -198,6 +234,10 @@ esp_err_t esp_a2d_source_connect(esp_bd_addr_t remote_bda)
return ESP_ERR_INVALID_STATE;
}
if (g_a2dp_on_deinit || g_a2dp_source_ongoing_deinit) {
return ESP_ERR_INVALID_STATE;
}
bt_status_t stat;
btc_av_args_t arg;
btc_msg_t msg;
@ -220,6 +260,10 @@ esp_err_t esp_a2d_source_disconnect(esp_bd_addr_t remote_bda)
return ESP_ERR_INVALID_STATE;
}
if (g_a2dp_on_deinit || g_a2dp_source_ongoing_deinit) {
return ESP_ERR_INVALID_STATE;
}
bt_status_t stat;
btc_av_args_t arg;
btc_msg_t msg;
@ -242,6 +286,10 @@ esp_err_t esp_a2d_source_register_data_callback(esp_a2d_source_data_cb_t callbac
return ESP_ERR_INVALID_STATE;
}
if (g_a2dp_source_ongoing_deinit) {
return ESP_ERR_INVALID_STATE;
}
btc_msg_t msg;
msg.sig = BTC_SIG_API_CALL;
msg.pid = BTC_PID_A2DP;