Merge branch 'bugfix/btdm_a2dp_source_cleanup_bug' into 'master'
component/bt: Fix bug of a2dp source cleanup bug when connected See merge request idf/esp-idf!2042
This commit is contained in:
commit
a3cfbdb150
1 changed files with 17 additions and 3 deletions
|
@ -45,6 +45,8 @@
|
||||||
#include "btc_util.h"
|
#include "btc_util.h"
|
||||||
#include "esp_a2dp_api.h"
|
#include "esp_a2dp_api.h"
|
||||||
#include "sbc_encoder.h"
|
#include "sbc_encoder.h"
|
||||||
|
#include "future.h"
|
||||||
|
#include <assert.h>
|
||||||
|
|
||||||
#if BTC_AV_SRC_INCLUDED
|
#if BTC_AV_SRC_INCLUDED
|
||||||
|
|
||||||
|
@ -176,6 +178,7 @@ static void btc_a2dp_source_encoder_init(void);
|
||||||
|
|
||||||
static tBTC_A2DP_SOURCE_CB btc_aa_src_cb;
|
static tBTC_A2DP_SOURCE_CB btc_aa_src_cb;
|
||||||
static int btc_a2dp_source_state = BTC_A2DP_SOURCE_STATE_OFF;
|
static int btc_a2dp_source_state = BTC_A2DP_SOURCE_STATE_OFF;
|
||||||
|
static future_t *btc_a2dp_source_future = NULL;
|
||||||
static xTaskHandle btc_aa_src_task_hdl = NULL;
|
static xTaskHandle btc_aa_src_task_hdl = NULL;
|
||||||
static QueueHandle_t btc_aa_src_data_queue = NULL;
|
static QueueHandle_t btc_aa_src_data_queue = NULL;
|
||||||
static QueueHandle_t btc_aa_src_ctrl_queue = NULL;
|
static QueueHandle_t btc_aa_src_ctrl_queue = NULL;
|
||||||
|
@ -360,7 +363,12 @@ void btc_a2dp_source_shutdown(void)
|
||||||
APPL_TRACE_EVENT("## A2DP SOURCE STOP MEDIA THREAD ##\n");
|
APPL_TRACE_EVENT("## A2DP SOURCE STOP MEDIA THREAD ##\n");
|
||||||
|
|
||||||
// Exit thread
|
// Exit thread
|
||||||
|
btc_a2dp_source_state = BTC_A2DP_SOURCE_STATE_SHUTTING_DOWN;
|
||||||
|
btc_a2dp_source_future = future_new();
|
||||||
|
assert(btc_a2dp_source_future);
|
||||||
btc_a2dp_source_ctrl_post(BTC_MEDIA_TASK_CLEAN_UP, NULL);
|
btc_a2dp_source_ctrl_post(BTC_MEDIA_TASK_CLEAN_UP, NULL);
|
||||||
|
future_await(btc_a2dp_source_future);
|
||||||
|
btc_a2dp_source_future = NULL;
|
||||||
|
|
||||||
vTaskDelete(btc_aa_src_task_hdl);
|
vTaskDelete(btc_aa_src_task_hdl);
|
||||||
btc_aa_src_task_hdl = NULL;
|
btc_aa_src_task_hdl = NULL;
|
||||||
|
@ -528,6 +536,9 @@ void btc_a2dp_source_setup_codec(void)
|
||||||
*******************************************************************************/
|
*******************************************************************************/
|
||||||
BT_HDR *btc_a2dp_source_audio_readbuf(void)
|
BT_HDR *btc_a2dp_source_audio_readbuf(void)
|
||||||
{
|
{
|
||||||
|
if (btc_a2dp_source_state != BTC_A2DP_SOURCE_STATE_ON){
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
return fixed_queue_try_dequeue(btc_aa_src_cb.TxAaQ);
|
return fixed_queue_try_dequeue(btc_aa_src_cb.TxAaQ);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1459,6 +1470,10 @@ 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){
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
if (btc_aa_src_cb.is_tx_timer == TRUE) {
|
if (btc_aa_src_cb.is_tx_timer == TRUE) {
|
||||||
btc_a2dp_source_send_aa_frame();
|
btc_a2dp_source_send_aa_frame();
|
||||||
} else {
|
} else {
|
||||||
|
@ -1608,9 +1623,6 @@ static void btc_a2dp_source_thread_init(UNUSED_ATTR void *context)
|
||||||
|
|
||||||
static void btc_a2dp_source_thread_cleanup(UNUSED_ATTR void *context)
|
static void btc_a2dp_source_thread_cleanup(UNUSED_ATTR void *context)
|
||||||
{
|
{
|
||||||
/* make sure no channels are restarted while shutting down */
|
|
||||||
btc_a2dp_source_state = BTC_A2DP_SOURCE_STATE_SHUTTING_DOWN;
|
|
||||||
|
|
||||||
btc_a2dp_control_set_datachnl_stat(FALSE);
|
btc_a2dp_control_set_datachnl_stat(FALSE);
|
||||||
/* Clear media task flag */
|
/* Clear media task flag */
|
||||||
btc_a2dp_source_state = BTC_A2DP_SOURCE_STATE_OFF;
|
btc_a2dp_source_state = BTC_A2DP_SOURCE_STATE_OFF;
|
||||||
|
@ -1618,6 +1630,8 @@ static void btc_a2dp_source_thread_cleanup(UNUSED_ATTR void *context)
|
||||||
btc_a2dp_control_cleanup();
|
btc_a2dp_control_cleanup();
|
||||||
|
|
||||||
fixed_queue_free(btc_aa_src_cb.TxAaQ, osi_free_func);
|
fixed_queue_free(btc_aa_src_cb.TxAaQ, osi_free_func);
|
||||||
|
|
||||||
|
future_ready(btc_a2dp_source_future, NULL);
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif /* BTC_AV_INCLUDED */
|
#endif /* BTC_AV_INCLUDED */
|
||||||
|
|
Loading…
Reference in a new issue