diff --git a/components/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_sink.c b/components/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_sink.c index 1316bbfb49..999796732a 100644 --- a/components/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_sink.c +++ b/components/bt/host/bluedroid/btc/profile/std/a2dp/btc_a2dp_sink.c @@ -110,12 +110,18 @@ typedef struct { UINT32 sample_rate; } tBTC_A2DP_SINK_CB; +typedef struct { + uint16_t expected_seq_num; + bool seq_num_recount; +} a2dp_sink_media_pkt_seq_num_t; + typedef struct { tBTC_A2DP_SINK_CB btc_aa_snk_cb; osi_thread_t *btc_aa_snk_task_hdl; OI_CODEC_SBC_DECODER_CONTEXT context; OI_UINT32 contextData[CODEC_DATA_WORDS(2, SBC_CODEC_FAST_FILTER_BUFFERS)]; OI_INT16 pcmData[15 * SBC_MAX_SAMPLES_PER_FRAME * SBC_MAX_CHANNELS]; + a2dp_sink_media_pkt_seq_num_t media_pkt_seq_num; } a2dp_sink_local_param_t; static void btc_a2dp_sink_thread_init(UNUSED_ATTR void *context); @@ -319,6 +325,10 @@ static BOOLEAN btc_a2dp_sink_clear_track(void) void btc_a2dp_sink_set_rx_flush(BOOLEAN enable) { APPL_TRACE_EVENT("## DROP RX %d ##\n", enable); + if (enable == FALSE) { + a2dp_sink_local_param.media_pkt_seq_num.expected_seq_num = 0x1; + a2dp_sink_local_param.media_pkt_seq_num.seq_num_recount = true; + } a2dp_sink_local_param.btc_aa_snk_cb.rx_flush = enable; } @@ -549,6 +559,18 @@ static void btc_a2dp_sink_handle_inc_media(tBT_SBC_HDR *p_msg) return; } + if (p_msg->layer_specific != a2dp_sink_local_param.media_pkt_seq_num.expected_seq_num) { + /* Because the sequence number of some devices is not recounted */ + if (!a2dp_sink_local_param.media_pkt_seq_num.seq_num_recount || + a2dp_sink_local_param.media_pkt_seq_num.expected_seq_num != 0x1) { + APPL_TRACE_WARNING("Sequence numbers error, recv:0x%x, expect:0x%x, recount:0x%x", + p_msg->layer_specific, a2dp_sink_local_param.media_pkt_seq_num.expected_seq_num, + a2dp_sink_local_param.media_pkt_seq_num.seq_num_recount); + } + } + a2dp_sink_local_param.media_pkt_seq_num.expected_seq_num = p_msg->layer_specific + 1; + a2dp_sink_local_param.media_pkt_seq_num.seq_num_recount = false; + APPL_TRACE_DEBUG("Number of sbc frames %d, frame_len %d\n", num_sbc_frames, sbc_frame_len); for (count = 0; count < num_sbc_frames && sbc_frame_len != 0; count ++) { diff --git a/components/bt/host/bluedroid/stack/btu/btu_hcif.c b/components/bt/host/bluedroid/stack/btu/btu_hcif.c index 1f88bfd23d..6abbdedb7b 100644 --- a/components/bt/host/bluedroid/stack/btu/btu_hcif.c +++ b/components/bt/host/bluedroid/stack/btu/btu_hcif.c @@ -111,12 +111,15 @@ static void btu_hcif_rem_oob_request_evt (UINT8 *p); #if (SMP_INCLUDED == TRUE) static void btu_hcif_simple_pair_complete_evt (UINT8 *p); #endif ///SMP_INCLUDED == TRUE +static void btu_hcif_link_supv_to_changed_evt (UINT8 *p); #if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE static void btu_hcif_enhanced_flush_complete_evt (void); #endif #if (BTM_SSR_INCLUDED == TRUE) static void btu_hcif_ssr_evt (UINT8 *p, UINT16 evt_len); +#else +static void btu_hcif_ssr_evt_dump (UINT8 *p, UINT16 evt_len); #endif /* BTM_SSR_INCLUDED == TRUE */ #if BLE_INCLUDED == TRUE @@ -300,11 +303,13 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) case HCI_ESCO_CONNECTION_CHANGED_EVT: btu_hcif_esco_connection_chg_evt (p); break; -#if (BTM_SSR_INCLUDED == TRUE) case HCI_SNIFF_SUB_RATE_EVT: +#if (BTM_SSR_INCLUDED == TRUE) btu_hcif_ssr_evt (p, hci_evt_len); - break; +#else + btu_hcif_ssr_evt_dump (p, hci_evt_len); #endif /* BTM_SSR_INCLUDED == TRUE */ + break; case HCI_RMT_HOST_SUP_FEAT_NOTIFY_EVT: btu_hcif_host_support_evt (p); break; @@ -338,6 +343,9 @@ void btu_hcif_process_event (UNUSED_ATTR UINT8 controller_id, BT_HDR *p_msg) btu_hcif_keypress_notif_evt (p); break; #endif ///SMP_INCLUDED == TRUE + case HCI_LINK_SUPER_TOUT_CHANGED_EVT: + btu_hcif_link_supv_to_changed_evt (p); + break; #if L2CAP_NON_FLUSHABLE_PB_INCLUDED == TRUE case HCI_ENHANCED_FLUSH_COMPLETE_EVT: btu_hcif_enhanced_flush_complete_evt (); @@ -651,6 +659,7 @@ static void btu_hcif_connection_comp_evt (UINT8 *p) btm_sco_connected (status, bda, handle, &esco_data); } #endif /* BTM_SCO_INCLUDED */ + HCI_TRACE_WARNING("hcif conn complete: hdl 0x%x, st 0x%x", handle, status); } @@ -707,9 +716,7 @@ static void btu_hcif_disconnection_comp_evt (UINT8 *p) handle = HCID_GET_HANDLE (handle); - if (reason != HCI_ERR_PEER_USER && reason != HCI_ERR_CONN_CAUSE_LOCAL_HOST) { - HCI_TRACE_WARNING("DiscCmpl evt: hdl=%d, rsn=0x%x", handle, reason); - } + HCI_TRACE_WARNING("hcif disc complete: hdl 0x%x, rsn 0x%x", handle, reason); #if BTM_SCO_INCLUDED == TRUE /* If L2CAP doesn't know about it, send it to SCO */ @@ -1554,6 +1561,8 @@ static void btu_hcif_mode_change_evt (UINT8 *p) btm_sco_chk_pend_unpark (status, handle); #endif btm_pm_proc_mode_change (status, handle, current_mode, interval); + HCI_TRACE_WARNING("hcif mode change: hdl 0x%x, mode %d, intv %d, status 0x%x", + handle, current_mode, interval, status); /* #if (HID_DEV_INCLUDED == TRUE) && (HID_DEV_PM_INCLUDED == TRUE) @@ -1576,6 +1585,21 @@ static void btu_hcif_ssr_evt (UINT8 *p, UINT16 evt_len) { btm_pm_proc_ssr_evt(p, evt_len); } +#else +static void btu_hcif_ssr_evt_dump (UINT8 *p, UINT16 evt_len) +{ + UINT8 status; + UINT16 handle; + UINT16 max_tx_lat; + UINT16 max_rx_lat; + + STREAM_TO_UINT8 (status, p); + STREAM_TO_UINT16 (handle, p); + STREAM_TO_UINT16 (max_tx_lat, p); + STREAM_TO_UINT16 (max_rx_lat, p); + + HCI_TRACE_WARNING("hcif ssr evt: st 0x%x, hdl 0x%x, tx_lat %d rx_lat %d", status, handle, max_tx_lat, max_rx_lat); +} #endif /******************************************************************************* @@ -1920,6 +1944,27 @@ static void btu_hcif_simple_pair_complete_evt (UINT8 *p) btm_simple_pair_complete(p); } #endif ///SMP_INCLUDED == TRUE + +/******************************************************************************* +** +** Function btu_hcif_link_supv_to_changed_evt +** +** Description Process event HCI_LINK_SUPER_TOUT_CHANGED_EVT +** +** Returns void +** +*******************************************************************************/ +static void btu_hcif_link_supv_to_changed_evt (UINT8 *p) +{ + UINT16 handle; + UINT16 supv_to; + + STREAM_TO_UINT16(handle, p); + STREAM_TO_UINT16(supv_to, p); + + HCI_TRACE_WARNING("hcif link supv_to changed: hdl 0x%x, supv_to %d", handle, supv_to); +} + /******************************************************************************* ** ** Function btu_hcif_enhanced_flush_complete_evt diff --git a/components/bt/host/bluedroid/stack/hcic/hcicmds.c b/components/bt/host/bluedroid/stack/hcic/hcicmds.c index 80517dcdb2..3b52804408 100644 --- a/components/bt/host/bluedroid/stack/hcic/hcicmds.c +++ b/components/bt/host/bluedroid/stack/hcic/hcicmds.c @@ -191,6 +191,7 @@ BOOLEAN btsnd_hcic_disconnect (UINT16 handle, UINT8 reason) UINT8_TO_STREAM (pp, reason); btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); + HCI_TRACE_WARNING("hci cmd send: disconnect: hdl 0x%x, rsn:0x%x", handle, reason); return (TRUE); } @@ -776,6 +777,8 @@ BOOLEAN btsnd_hcic_sniff_mode (UINT16 handle, UINT16 max_sniff_period, UINT16_TO_STREAM (pp, sniff_timeout); btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); + HCI_TRACE_WARNING("hci cmd send: sniff: hdl 0x%x, intv(%d %d)", + handle, min_sniff_period, max_sniff_period); return (TRUE); } @@ -799,6 +802,7 @@ BOOLEAN btsnd_hcic_exit_sniff_mode (UINT16 handle) UINT16_TO_STREAM (pp, handle); btu_hcif_send_cmd (LOCAL_BR_EDR_CONTROLLER_ID, p); + HCI_TRACE_WARNING("hci cmd send: unsniff: hdl 0x%x", handle); return TRUE; }