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

Commit afff94c1 authored by Jakub Rotkiewicz's avatar Jakub Rotkiewicz
Browse files

avdt: inline avdt_l2c_disconnect function

Bug: 329809288
Flag: EXEMPT - minor refactor
Test: mmm packages/modules/Bluetooth
Change-Id: Ic2c3e51d6767c8c32e6cc730bd02e6dac0f8046b
parent 5d1ac10b
Loading
Loading
Loading
Loading
+7 −6
Original line number Original line Diff line number Diff line
@@ -568,11 +568,11 @@ void avdt_ad_open_req(uint8_t type, AvdtpCcb* p_ccb, AvdtpScb* p_scb, uint8_t ro
 *
 *
 ******************************************************************************/
 ******************************************************************************/
void avdt_ad_close_req(uint8_t type, AvdtpCcb* p_ccb, AvdtpScb* p_scb) {
void avdt_ad_close_req(uint8_t type, AvdtpCcb* p_ccb, AvdtpScb* p_scb) {
  uint8_t tcid;
  uint16_t lcid;
  AvdtpTransportChannel* p_tbl;
  AvdtpTransportChannel* p_tbl;


  p_tbl = avdt_ad_tc_tbl_by_type(type, p_ccb, p_scb);
  p_tbl = avdt_ad_tc_tbl_by_type(type, p_ccb, p_scb);
  log::verbose("avdt_ad_close_req state: {}", p_tbl->state);
  log::verbose("state: {}", p_tbl->state);


  switch (p_tbl->state) {
  switch (p_tbl->state) {
    case AVDT_AD_ST_UNUSED:
    case AVDT_AD_ST_UNUSED:
@@ -583,10 +583,11 @@ void avdt_ad_close_req(uint8_t type, AvdtpCcb* p_ccb, AvdtpScb* p_scb) {
      avdt_ad_tc_close_ind(p_tbl);
      avdt_ad_tc_close_ind(p_tbl);
      break;
      break;
    default:
    default:
      /* get tcid from type, scb */
      lcid = p_tbl->lcid;
      tcid = avdt_ad_type_to_tcid(type, p_scb);

      /* call l2cap disconnect req */
      /* call l2cap disconnect req */
      avdt_l2c_disconnect(avdtp_cb.ad.rt_tbl[avdt_ccb_to_idx(p_ccb)][tcid].lcid);
      if (!L2CA_DisconnectReq(lcid)) {
        log::warn("Unable to disconnect L2CAP lcid: 0x{:04x}", lcid);
      }
      avdt_ad_tc_close_ind(p_tbl);
  }
  }
}
}
+0 −2
Original line number Original line Diff line number Diff line
@@ -950,8 +950,6 @@ extern const tL2CAP_APPL_INFO avdt_l2c_appl;
/* reject message event lookup table */
/* reject message event lookup table */
extern const uint8_t avdt_msg_rej_2_evt[];
extern const uint8_t avdt_msg_rej_2_evt[];


void avdt_l2c_disconnect(uint16_t lcid);

constexpr uint16_t kAvdtpMtu = 1024;
constexpr uint16_t kAvdtpMtu = 1024;


#endif /* AVDT_INT_H */
#endif /* AVDT_INT_H */
+16 −16
Original line number Original line Diff line number Diff line
@@ -216,7 +216,22 @@ void avdt_l2c_connect_ind_cback(const RawAddress& bd_addr, uint16_t lcid, uint16
  p_tbl->state = AVDT_AD_ST_CFG;
  p_tbl->state = AVDT_AD_ST_CFG;
}
}


static void avdt_on_l2cap_error(uint16_t lcid, uint16_t /* result */) { avdt_l2c_disconnect(lcid); }
static void avdt_on_l2cap_error(uint16_t lcid, uint16_t result) {
  AvdtpTransportChannel* p_tbl;

  log::warn("lcid: 0x{:04x}, result: {}", lcid, to_l2cap_result_code(result));
  if (!L2CA_DisconnectReq(lcid)) {
    log::warn("Unable to disconnect L2CAP lcid: 0x{:04x}", lcid);
  }

  /* look up info for this channel */
  p_tbl = avdt_ad_tc_tbl_by_lcid(lcid);
  if (p_tbl == NULL) {
    log::warn("Adaptation layer transport channel table is NULL");
    return;
  }
  avdt_ad_tc_close_ind(p_tbl);
}


/*******************************************************************************
/*******************************************************************************
 *
 *
@@ -354,21 +369,6 @@ void avdt_l2c_disconnect_ind_cback(uint16_t lcid, bool ack_needed) {
  }
  }
}
}


void avdt_l2c_disconnect(uint16_t lcid) {
  if (!L2CA_DisconnectReq(lcid)) {
    log::warn("Unable to disconnect L2CAP cid:{}", lcid);
  }

  AvdtpTransportChannel* p_tbl;

  log::verbose("avdt_l2c_disconnect_cfm_cback lcid: {}", lcid);
  /* look up info for this channel */
  p_tbl = avdt_ad_tc_tbl_by_lcid(lcid);
  if (p_tbl != NULL) {
    avdt_ad_tc_close_ind(p_tbl);
  }
}

/*******************************************************************************
/*******************************************************************************
 *
 *
 * Function         avdt_l2c_congestion_ind_cback
 * Function         avdt_l2c_congestion_ind_cback