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

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

A2DP: Disconnect AVDTP only when there is a link

bta_av_cb.conn_lcb within AV control block is the index bitmask of all
used LCBs which is shared between all connected links, and is changed
when related AVDTP signal channel up or down. When disconnecting the
AVDTP link, we should only check its bitmask and ignore others.

Bug: 145326274
Bug: 146849922
Test: Connect with multiple A2DP sinks
Change-Id: I49a602dbcd76254d9b40eb7b19ffd16d3b45ba3d
parent f0e59bfe
Loading
Loading
Loading
Loading
+12 −5
Original line number Diff line number Diff line
@@ -1062,18 +1062,21 @@ void bta_av_disconnect_req(tBTA_AV_SCB* p_scb,
                           UNUSED_ATTR tBTA_AV_DATA* p_data) {
  tBTA_AV_RCB* p_rcb;

  APPL_TRACE_WARNING("%s: conn_lcb: 0x%x peer_addr: %s", __func__,
                     bta_av_cb.conn_lcb,
                     p_scb->PeerAddress().ToString().c_str());
  APPL_TRACE_API("%s: conn_lcb: 0x%x peer_addr: %s", __func__,
                 bta_av_cb.conn_lcb, p_scb->PeerAddress().ToString().c_str());

  alarm_cancel(bta_av_cb.link_signalling_timer);
  alarm_cancel(p_scb->avrc_ct_timer);

  if (bta_av_cb.conn_lcb) {
  // conn_lcb is the index bitmask of all used LCBs, and since LCB and SCB use
  // the same index, it should be safe to use SCB index here.
  if ((bta_av_cb.conn_lcb & (1 << p_scb->hdi)) != 0) {
    p_rcb = bta_av_get_rcb_by_shdl((uint8_t)(p_scb->hdi + 1));
    if (p_rcb) bta_av_del_rc(p_rcb);
    AVDT_DisconnectReq(p_scb->PeerAddress(), &bta_av_proc_stream_evt);
  } else {
    APPL_TRACE_WARNING("%s: conn_lcb=0x%x bta_handle=0x%x (hdi=%u) no link",
                       __func__, bta_av_cb.conn_lcb, p_scb->hndl, p_scb->hdi);
    bta_av_ssm_execute(p_scb, BTA_AV_AVDT_DISCONNECT_EVT, NULL);
  }
}
@@ -2692,9 +2695,13 @@ void bta_av_rcfg_failed(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
  } else {
    /* open failed. try again */
    p_scb->num_recfg++;
    if (bta_av_cb.conn_lcb) {
    // conn_lcb is the index bitmask of all used LCBs, and since LCB and SCB use
    // the same index, it should be safe to use SCB index here.
    if ((bta_av_cb.conn_lcb & (1 << p_scb->hdi)) != 0) {
      AVDT_DisconnectReq(p_scb->PeerAddress(), &bta_av_proc_stream_evt);
    } else {
      APPL_TRACE_WARNING("%s: conn_lcb=0x%x bta_handle=0x%x (hdi=%u) no link",
                         __func__, bta_av_cb.conn_lcb, p_scb->hndl, p_scb->hdi);
      bta_av_connect_req(p_scb, NULL);
    }
  }
+3 −2
Original line number Diff line number Diff line
@@ -1474,7 +1474,7 @@ void bta_av_sig_chg(tBTA_AV_DATA* p_data) {
#endif
  else {
    /* disconnected. */
    APPL_TRACE_DEBUG("%s: bta_av_cb.conn_lcb is %d", __func__,
    APPL_TRACE_DEBUG("%s: bta_av_cb.conn_lcb=0x%x", __func__,
                     bta_av_cb.conn_lcb);

    p_lcb = bta_av_find_lcb(p_data->str_msg.bd_addr, BTA_AV_LCB_FREE);
@@ -1500,7 +1500,8 @@ void bta_av_sig_chg(tBTA_AV_DATA* p_data) {
      }
    }
  }
  APPL_TRACE_DEBUG("%s: sig_chg conn_lcb: 0x%x", __func__, p_cb->conn_lcb);
  APPL_TRACE_DEBUG("%s: bta_av_cb.conn_lcb=0x%x after sig_chg", __func__,
                   p_cb->conn_lcb);
}

/*******************************************************************************