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

Commit 063a6a5d authored by Jakub Rotkiewicz's avatar Jakub Rotkiewicz
Browse files

avdt: refactor AvdtpTransportChannel

Remove cfg_flags and add role attribute instead.

Bug: 329809288
Flag: EXEMPT - minor refactor
Test: mmm packages/modules/Bluetooth
Change-Id: I9b0e536a613c2bbe0a7c62009004f6b6cc479dad
parent 9d4701b5
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -250,7 +250,7 @@ AvdtpTransportChannel* avdt_ad_tc_tbl_alloc(AvdtpCcb* p_ccb) {

  /* initialize entry */
  p_tbl->peer_mtu = L2CAP_DEFAULT_MTU;
  p_tbl->cfg_flags = 0;
  p_tbl->role = tAVDT_ROLE::AVDT_UNKNOWN;
  p_tbl->ccb_idx = avdt_ccb_to_idx(p_ccb);
  p_tbl->state = AVDT_AD_ST_IDLE;
  return p_tbl;
@@ -297,7 +297,7 @@ void avdt_ad_tc_close_ind(AvdtpTransportChannel* p_tbl) {
  close.old_tc_state = p_tbl->state;
  /* clear avdt_ad_tc_tbl entry */
  p_tbl->state = AVDT_AD_ST_UNUSED;
  p_tbl->cfg_flags = 0;
  p_tbl->role = tAVDT_ROLE::AVDT_UNKNOWN;
  p_tbl->peer_mtu = L2CAP_DEFAULT_MTU;

  /* if signaling channel, notify ccb that channel close */
@@ -356,10 +356,7 @@ void avdt_ad_tc_open_ind(AvdtpTransportChannel* p_tbl) {

    p_ccb = avdt_ccb_by_idx(p_tbl->ccb_idx);
    /* use err_param to indicate the role of connection */
    evt.err_param = static_cast<uint8_t>(tAVDT_ROLE::AVDT_INT);
    if (p_tbl->cfg_flags & AVDT_L2C_CFG_CONN_ACP) {
      evt.err_param = static_cast<uint8_t>(tAVDT_ROLE::AVDT_ACP);
    }
    evt.err_param = static_cast<uint8_t>(p_tbl->role);
    tAVDT_CCB_EVT avdt_ccb_evt;
    avdt_ccb_evt.msg.hdr = evt;
    avdt_ccb_event(p_ccb, AVDT_CCB_LL_OPEN_EVT, &avdt_ccb_evt);
+9 −10
Original line number Diff line number Diff line
@@ -306,13 +306,6 @@ enum {
/* 2 channels(1 media, 1 report) for each SEP and one for signalling */
#define AVDT_NUM_RT_TBL (AVDT_NUM_SEPS * AVDT_CHAN_NUM_TYPES + 1)

/* Adaptation layer number of transport channel table entries - moved to target.h
#define AVDT_NUM_TC_TBL     (AVDT_NUM_SEPS + AVDT_NUM_LINKS) */

/* Configuration flags. AvdtpTransportChannel.cfg_flags */
#define AVDT_L2C_CFG_CONN_INT (1 << 2)
#define AVDT_L2C_CFG_CONN_ACP (1 << 3)

/* "states" used in transport channel table */
enum tTRANSPORT_CHANNEL_STATE : uint8_t {
  AVDT_AD_ST_UNUSED = 0,  /* Unused - unallocated */
@@ -677,7 +670,13 @@ private:
class AvdtpTransportChannel {
public:
  AvdtpTransportChannel()
      : peer_mtu(0), my_mtu(0), lcid(0), tcid(0), ccb_idx(0), state(0), cfg_flags(0) {}
      : peer_mtu(0),
        my_mtu(0),
        lcid(0),
        tcid(0),
        ccb_idx(0),
        state(0),
        role(tAVDT_ROLE::AVDT_UNKNOWN) {}

  void Reset() {
    peer_mtu = 0;
@@ -686,7 +685,7 @@ public:
    tcid = 0;
    ccb_idx = 0;
    state = 0;
    cfg_flags = 0;
    role = tAVDT_ROLE::AVDT_UNKNOWN;
  }

  uint16_t peer_mtu;  // L2CAP MTU of the peer device
@@ -695,7 +694,7 @@ public:
  uint8_t tcid;       // Transport channel ID
  uint8_t ccb_idx;    // Channel control block for with this transport channel
  uint8_t state;      // Transport channel state
  uint8_t cfg_flags;  // L2CAP configuration flags
  tAVDT_ROLE role;    // Role for the establishment of the AVDTP signaling channel
};

/**
+2 −2
Original line number Diff line number Diff line
@@ -163,7 +163,7 @@ void avdt_l2c_connect_ind_cback(const RawAddress& bd_addr, uint16_t lcid, uint16
      p_tbl->tcid = AVDT_CHAN_SIG;
      p_tbl->lcid = lcid;
      p_tbl->state = AVDT_AD_ST_SEC_ACP;
      p_tbl->cfg_flags = AVDT_L2C_CFG_CONN_ACP;
      p_tbl->role = tAVDT_ROLE::AVDT_ACP;

      if (interop_match_addr(INTEROP_2MBPS_LINK_ONLY, &bd_addr)) {
        // Disable 3DH packets for AVDT ACL to improve sensitivity on HS
@@ -286,7 +286,7 @@ void avdt_l2c_connect_cfm_cback(uint16_t lcid, tL2CAP_CONN result) {

  p_tbl->state = AVDT_AD_ST_SEC_INT;
  p_tbl->lcid = lcid;
  p_tbl->cfg_flags = AVDT_L2C_CFG_CONN_INT;
  p_tbl->role = tAVDT_ROLE::AVDT_INT;

  if (interop_match_addr(INTEROP_2MBPS_LINK_ONLY, (const RawAddress*)&p_ccb->peer_addr)) {
    // Disable 3DH packets for AVDT ACL to improve sensitivity on HS