Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit b7ab2988 authored by Cheney Ni's avatar Cheney Ni
Browse files

A2DP: Don't override the SDP handle if there is processing

The stack could handle only one A2DP find service a time. If there were
2 sinks to reconnect at the same time, the SCB handle for SDP might be
override by the later, but caused this SDP event was routed to worng
handler. And, the earlier would be stuck at opening / closing state to
cause abnormal behavior.
This CL prevents such overridden, and uses Bluetooth address within SDP
results to find its handler.

Bug: 145326274
Test: Reconnect to multiple A2DP sinks
Change-Id: I256859f8c70cc948c03b8ac90bf600bef4fdc3a0
parent f095106b
Loading
Loading
Loading
Loading
+16 −6
Original line number Diff line number Diff line
@@ -544,12 +544,22 @@ static void bta_av_a2dp_sdp_cback(bool found, tA2DP_Service* p_service,
  APPL_TRACE_DEBUG("%s: peer %s : found=%s", __func__,
                   peer_address.ToString().c_str(), (found) ? "true" : "false");

  tBTA_AV_SCB* p_scb = bta_av_hndl_to_scb(bta_av_cb.handle);
  tBTA_AV_SCB* p_scb = NULL;
  if (peer_address != RawAddress::kEmpty) {
    p_scb = bta_av_addr_to_scb(peer_address);
  }
  if (p_scb == NULL) {
    p_scb = bta_av_hndl_to_scb(bta_av_cb.handle);
  }
  if (p_scb == NULL) {
    APPL_TRACE_ERROR("%s: no scb found for SDP handle(0x%x)", __func__,
                     bta_av_cb.handle);
    return;
  }
  if (bta_av_cb.handle != p_scb->hndl) {
    APPL_TRACE_WARNING("%s: SDP bta_handle expected=0x%x processing=0x%x",
                       __func__, bta_av_cb.handle, p_scb->hndl);
  }

  if (!found) {
    APPL_TRACE_ERROR("%s: peer %s A2DP service discovery failed", __func__,
@@ -584,7 +594,7 @@ static void bta_av_a2dp_sdp_cback(bool found, tA2DP_Service* p_service,
  } else {
    p_scb->SetAvdtpVersion(0);
  }
  p_msg->hdr.layer_specific = bta_av_cb.handle;
  p_msg->hdr.layer_specific = p_scb->hndl;

  bta_sys_sendmsg(p_msg);
}
@@ -848,9 +858,6 @@ void bta_av_do_disc_a2dp(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {

  bta_sys_app_open(BTA_ID_AV, p_scb->app_id, p_scb->PeerAddress());

  /* only one A2DP find service is active at a time */
  bta_av_cb.handle = p_scb->hndl;

  /* set up parameters */
  db_params.db_len = BTA_AV_DISC_BUF_SIZE;
  db_params.num_attr = 3;
@@ -875,7 +882,10 @@ void bta_av_do_disc_a2dp(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
        "sdp_uuid=0x%x : status=%d",
        __func__, p_scb->PeerAddress().ToString().c_str(), p_scb->uuid_int,
        sdp_uuid, find_service_status);
    bta_av_a2dp_sdp_cback(false, nullptr, RawAddress::kEmpty);
    bta_av_a2dp_sdp_cback(false, nullptr, p_scb->PeerAddress());
  } else {
    /* only one A2DP find service is active at a time */
    bta_av_cb.handle = p_scb->hndl;
  }
}

+1 −0
Original line number Diff line number Diff line
@@ -664,6 +664,7 @@ extern void bta_av_sink_data_cback(uint8_t handle, BT_HDR* p_pkt,
 ****************************************************************************/
/* utility functions */
extern tBTA_AV_SCB* bta_av_hndl_to_scb(uint16_t handle);
tBTA_AV_SCB* bta_av_addr_to_scb(const RawAddress& bd_addr);
extern bool bta_av_chk_start(tBTA_AV_SCB* p_scb);
extern void bta_av_restore_switch(void);
extern void bta_av_conn_cback(uint8_t handle, const RawAddress& bd_addr,
+1 −1
Original line number Diff line number Diff line
@@ -260,7 +260,7 @@ static void bta_av_api_enable(tBTA_AV_DATA* p_data) {
 * Returns          void
 *
 ******************************************************************************/
static tBTA_AV_SCB* bta_av_addr_to_scb(const RawAddress& bd_addr) {
tBTA_AV_SCB* bta_av_addr_to_scb(const RawAddress& bd_addr) {
  tBTA_AV_SCB* p_scb = NULL;
  int xx;