diff --git a/components/bt/host/bluedroid/btc/profile/std/hf_client/bta_hf_client_co.c b/components/bt/host/bluedroid/btc/profile/std/hf_client/bta_hf_client_co.c index b8b2ea40c7..99b9280304 100644 --- a/components/bt/host/bluedroid/btc/profile/std/hf_client/bta_hf_client_co.c +++ b/components/bt/host/bluedroid/btc/profile/std/hf_client/bta_hf_client_co.c @@ -73,8 +73,8 @@ static bta_hf_client_co_cb_t *bta_hf_client_co_cb_ptr; #define bta_hf_client_co_cb (*bta_hf_client_co_cb_ptr) #endif /* HFP_DYNAMIC_MEMORY == FALSE */ -static UINT8 hf_air_mode; -static UINT8 hf_inout_pkt_size; +static UINT8 hf_air_mode = BTM_SCO_AIR_MODE_UNKNOWN; +static UINT8 hf_inout_pkt_size = 0; /******************************************************************************* ** @@ -223,6 +223,9 @@ void bta_hf_client_sco_co_open(UINT16 handle, UINT8 air_mode, UINT8 inout_pkt_si #if (HFP_DYNAMIC_MEMORY == TRUE) error_exit:; + hf_air_mode = BTM_SCO_AIR_MODE_UNKNOWN; + hf_inout_pkt_size = 0; + if (bta_hf_client_co_cb_ptr) { osi_free(bta_hf_client_co_cb_ptr); bta_hf_client_co_cb_ptr = NULL; @@ -271,6 +274,9 @@ void bta_hf_client_sco_co_close(void) } else { // Nothing to do } + + hf_air_mode = BTM_SCO_AIR_MODE_UNKNOWN; + hf_inout_pkt_size = 0; } /******************************************************************************* diff --git a/components/bt/host/bluedroid/stack/btu/btu_init.c b/components/bt/host/bluedroid/stack/btu/btu_init.c index 52ce3a6e15..80678bef82 100644 --- a/components/bt/host/bluedroid/stack/btu/btu_init.c +++ b/components/bt/host/bluedroid/stack/btu/btu_init.c @@ -129,12 +129,12 @@ void btu_free_core(void) #if (defined(GATT_INCLUDED) && GATT_INCLUDED == true) gatt_free(); #endif - btm_ble_free(); -#endif - btm_free(); #if SMP_INCLUDED == TRUE SMP_Free(); #endif + btm_ble_free(); +#endif + btm_free(); } /***************************************************************************** diff --git a/components/bt/host/bluedroid/stack/include/stack/btm_api.h b/components/bt/host/bluedroid/stack/include/stack/btm_api.h index b51ecb0069..641dd93f52 100644 --- a/components/bt/host/bluedroid/stack/include/stack/btm_api.h +++ b/components/bt/host/bluedroid/stack/include/stack/btm_api.h @@ -983,6 +983,7 @@ typedef UINT16 tBTM_SCO_CODEC_TYPE; #define BTM_SCO_AIR_MODE_A_LAW 1 #define BTM_SCO_AIR_MODE_CVSD 2 #define BTM_SCO_AIR_MODE_TRANSPNT 3 +#define BTM_SCO_AIR_MODE_UNKNOWN 0xFF typedef UINT8 tBTM_SCO_AIR_MODE_TYPE; /******************* diff --git a/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/main/bt_app_core.c b/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/main/bt_app_core.c index a46c60050f..7dee9e7f40 100644 --- a/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/main/bt_app_core.c +++ b/examples/bluetooth/bluedroid/classic_bt/a2dp_sink/main/bt_app_core.c @@ -26,7 +26,7 @@ static void bt_app_work_dispatched(bt_app_msg_t *msg); static xQueueHandle s_bt_app_task_queue = NULL; static xTaskHandle s_bt_app_task_handle = NULL; static xTaskHandle s_bt_i2s_task_handle = NULL; -static RingbufHandle_t ringbuf_i2s = NULL;; +static RingbufHandle_t s_ringbuf_i2s = NULL;; bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback) { @@ -123,18 +123,18 @@ static void bt_i2s_task_handler(void *arg) size_t bytes_written = 0; for (;;) { - data = (uint8_t *)xRingbufferReceive(ringbuf_i2s, &item_size, (portTickType)portMAX_DELAY); + data = (uint8_t *)xRingbufferReceive(s_ringbuf_i2s, &item_size, (portTickType)portMAX_DELAY); if (item_size != 0){ i2s_write(0, data, item_size, &bytes_written, portMAX_DELAY); - vRingbufferReturnItem(ringbuf_i2s,(void *)data); + vRingbufferReturnItem(s_ringbuf_i2s,(void *)data); } } } void bt_i2s_task_start_up(void) { - ringbuf_i2s = xRingbufferCreate(8 * 1024, RINGBUF_TYPE_BYTEBUF); - if(ringbuf_i2s == NULL){ + s_ringbuf_i2s = xRingbufferCreate(8 * 1024, RINGBUF_TYPE_BYTEBUF); + if(s_ringbuf_i2s == NULL){ return; } @@ -149,13 +149,15 @@ void bt_i2s_task_shut_down(void) s_bt_i2s_task_handle = NULL; } - vRingbufferDelete(ringbuf_i2s); - ringbuf_i2s = NULL; + if (s_ringbuf_i2s) { + vRingbufferDelete(s_ringbuf_i2s); + s_ringbuf_i2s = NULL; + } } size_t write_ringbuf(const uint8_t *data, size_t size) { - BaseType_t done = xRingbufferSend(ringbuf_i2s, (void *)data, size, (portTickType)portMAX_DELAY); + BaseType_t done = xRingbufferSend(s_ringbuf_i2s, (void *)data, size, (portTickType)portMAX_DELAY); if(done){ return size; } else { diff --git a/examples/bluetooth/bluedroid/coex/a2dp_gatts_coex/main/bt_app_core.c b/examples/bluetooth/bluedroid/coex/a2dp_gatts_coex/main/bt_app_core.c index a46c60050f..7dee9e7f40 100644 --- a/examples/bluetooth/bluedroid/coex/a2dp_gatts_coex/main/bt_app_core.c +++ b/examples/bluetooth/bluedroid/coex/a2dp_gatts_coex/main/bt_app_core.c @@ -26,7 +26,7 @@ static void bt_app_work_dispatched(bt_app_msg_t *msg); static xQueueHandle s_bt_app_task_queue = NULL; static xTaskHandle s_bt_app_task_handle = NULL; static xTaskHandle s_bt_i2s_task_handle = NULL; -static RingbufHandle_t ringbuf_i2s = NULL;; +static RingbufHandle_t s_ringbuf_i2s = NULL;; bool bt_app_work_dispatch(bt_app_cb_t p_cback, uint16_t event, void *p_params, int param_len, bt_app_copy_cb_t p_copy_cback) { @@ -123,18 +123,18 @@ static void bt_i2s_task_handler(void *arg) size_t bytes_written = 0; for (;;) { - data = (uint8_t *)xRingbufferReceive(ringbuf_i2s, &item_size, (portTickType)portMAX_DELAY); + data = (uint8_t *)xRingbufferReceive(s_ringbuf_i2s, &item_size, (portTickType)portMAX_DELAY); if (item_size != 0){ i2s_write(0, data, item_size, &bytes_written, portMAX_DELAY); - vRingbufferReturnItem(ringbuf_i2s,(void *)data); + vRingbufferReturnItem(s_ringbuf_i2s,(void *)data); } } } void bt_i2s_task_start_up(void) { - ringbuf_i2s = xRingbufferCreate(8 * 1024, RINGBUF_TYPE_BYTEBUF); - if(ringbuf_i2s == NULL){ + s_ringbuf_i2s = xRingbufferCreate(8 * 1024, RINGBUF_TYPE_BYTEBUF); + if(s_ringbuf_i2s == NULL){ return; } @@ -149,13 +149,15 @@ void bt_i2s_task_shut_down(void) s_bt_i2s_task_handle = NULL; } - vRingbufferDelete(ringbuf_i2s); - ringbuf_i2s = NULL; + if (s_ringbuf_i2s) { + vRingbufferDelete(s_ringbuf_i2s); + s_ringbuf_i2s = NULL; + } } size_t write_ringbuf(const uint8_t *data, size_t size) { - BaseType_t done = xRingbufferSend(ringbuf_i2s, (void *)data, size, (portTickType)portMAX_DELAY); + BaseType_t done = xRingbufferSend(s_ringbuf_i2s, (void *)data, size, (portTickType)portMAX_DELAY); if(done){ return size; } else {