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

Commit 99790249 authored by Myles Watson's avatar Myles Watson Committed by android-build-merger
Browse files

eSCO: Remove BTM_WBS_INCLUDED from the stack (2/5) am: b4b0ea1a

am: a1ce3bcd

Change-Id: Ief7ca14cda07fa76c94e1e31ef96b3f054cc96f4
parents 9da86c0b a1ce3bcd
Loading
Loading
Loading
Loading
+0 −10
Original line number Diff line number Diff line
@@ -341,10 +341,8 @@ void bta_ag_rfc_fail(tBTA_AG_SCB* p_scb, UNUSED_ATTR tBTA_AG_DATA* p_data) {
  p_scb->conn_handle = 0;
  p_scb->conn_service = 0;
  p_scb->peer_features = 0;
#if (BTM_WBS_INCLUDED == TRUE)
  p_scb->peer_codecs = BTA_AG_CODEC_CVSD;
  p_scb->sco_codec = BTA_AG_CODEC_CVSD;
#endif
  p_scb->role = 0;
  p_scb->svc_conn = false;
  p_scb->hsp_version = HSP_VERSION_1_2;
@@ -376,14 +374,12 @@ void bta_ag_rfc_close(tBTA_AG_SCB* p_scb, UNUSED_ATTR tBTA_AG_DATA* p_data) {
  /* reinitialize stuff */
  p_scb->conn_service = 0;
  p_scb->peer_features = 0;
#if (BTM_WBS_INCLUDED == TRUE)
  p_scb->peer_codecs = BTA_AG_CODEC_CVSD;
  p_scb->sco_codec = BTA_AG_CODEC_CVSD;
  /* Clear these flags upon SLC teardown */
  p_scb->codec_updated = false;
  p_scb->codec_fallback = false;
  p_scb->codec_msbc_settings = BTA_AG_SCO_MSBC_SETTINGS_T2;
#endif
  p_scb->role = 0;
  p_scb->post_sco = BTA_AG_POST_SCO_NONE;
  p_scb->svc_conn = false;
@@ -395,9 +391,7 @@ void bta_ag_rfc_close(tBTA_AG_SCB* p_scb, UNUSED_ATTR tBTA_AG_DATA* p_data) {

  /* stop timers */
  alarm_cancel(p_scb->ring_timer);
#if (BTM_WBS_INCLUDED == TRUE)
  alarm_cancel(p_scb->codec_negotiation_timer);
#endif

  close.hdr.handle = bta_ag_scb_to_idx(p_scb);
  close.hdr.app_id = p_scb->app_id;
@@ -762,9 +756,7 @@ void bta_ag_svc_conn_open(tBTA_AG_SCB* p_scb,
    evt.hdr.app_id = p_scb->app_id;
    evt.peer_feat = p_scb->peer_features;
    bdcpy(evt.bd_addr, p_scb->peer_addr);
#if (BTM_WBS_INCLUDED == TRUE)
    evt.peer_codec = p_scb->peer_codecs;
#endif

    if ((p_scb->call_ind != BTA_AG_CALL_INACTIVE) ||
        (p_scb->callsetup_ind != BTA_AG_CALLSETUP_NONE)) {
@@ -834,7 +826,6 @@ void bta_ag_rcvd_slc_ready(tBTA_AG_SCB* p_scb,
 *
 ******************************************************************************/
void bta_ag_setcodec(tBTA_AG_SCB* p_scb, tBTA_AG_DATA* p_data) {
#if (BTM_WBS_INCLUDED == TRUE)
  tBTA_AG_PEER_CODEC codec_type = p_data->api_setcodec.codec;
  tBTA_AG_VAL val;

@@ -864,5 +855,4 @@ void bta_ag_setcodec(tBTA_AG_SCB* p_scb, tBTA_AG_DATA* p_data) {
  }

  (*bta_ag_cb.p_cback)(BTA_AG_WBS_EVT, (tBTA_AG*)&val);
#endif
}
+0 −8
Original line number Diff line number Diff line
@@ -443,7 +443,6 @@ static uint8_t bta_ag_parse_chld(UNUSED_ATTR tBTA_AG_SCB* p_scb, char* p_s) {
  return (retval);
}

#if (BTM_WBS_INCLUDED == TRUE)
/*******************************************************************************
 *
 * Function         bta_ag_parse_bac
@@ -492,7 +491,6 @@ static tBTA_AG_PEER_CODEC bta_ag_parse_bac(tBTA_AG_SCB* p_scb, char* p_s) {

  return (retval);
}
#endif

/*******************************************************************************
 *
@@ -830,9 +828,7 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB* p_scb, uint16_t cmd, uint8_t arg_type,
  tBTA_AG_SCB* ag_scb;
  uint32_t i, ind_id;
  uint32_t bia_masked_out;
#if (BTM_WBS_INCLUDED == TRUE)
  tBTA_AG_PEER_CODEC codec_type, codec_sent;
#endif
  if (p_arg == NULL) {
    APPL_TRACE_ERROR("%s: p_arg is null, send error and return", __func__);
    bta_ag_send_error(p_scb, BTA_AG_ERR_INV_CHAR_IN_TSTR);
@@ -1173,7 +1169,6 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB* p_scb, uint16_t cmd, uint8_t arg_type,
      }
      break;

#if (BTM_WBS_INCLUDED == TRUE)
    case BTA_AG_AT_BAC_EVT:
      bta_ag_send_ok(p_scb);

@@ -1244,7 +1239,6 @@ void bta_ag_at_hfp_cback(tBTA_AG_SCB* p_scb, uint16_t cmd, uint8_t arg_type,
      bta_ag_send_ok(p_scb);
      bta_ag_sco_open(p_scb, NULL);
      break;
#endif

    default:
      bta_ag_send_error(p_scb, BTA_AG_ERR_OP_NOT_SUPPORTED);
@@ -1684,7 +1678,6 @@ void bta_ag_result(tBTA_AG_SCB* p_scb, tBTA_AG_DATA* p_data) {
  }
}

#if (BTM_WBS_INCLUDED == TRUE)
/*******************************************************************************
 *
 * Function         bta_ag_send_bcs
@@ -1722,7 +1715,6 @@ void bta_ag_send_bcs(tBTA_AG_SCB* p_scb, tBTA_AG_DATA* p_data) {
  APPL_TRACE_DEBUG("send +BCS codec is %d", codec_uuid);
  bta_ag_send_result(p_scb, BTA_AG_LOCAL_RES_BCS, NULL, codec_uuid);
}
#endif

/*******************************************************************************
 *
+3 −17
Original line number Diff line number Diff line
@@ -119,9 +119,7 @@ enum {
enum {
  BTA_AG_SCO_SHUTDOWN_ST,   /* no sco listening, all sco connections closed */
  BTA_AG_SCO_LISTEN_ST,     /* sco listening */
#if (BTM_WBS_INCLUDED == TRUE)
  BTA_AG_SCO_CODEC_ST,      /* sco codec negotiation */
#endif
  BTA_AG_SCO_OPENING_ST,    /* sco connection opening */
  BTA_AG_SCO_OPEN_CL_ST,    /* opening sco connection being closed */
  BTA_AG_SCO_OPEN_XFER_ST,  /* opening sco connection being transferred */
@@ -199,9 +197,7 @@ typedef union {
  tBTA_AG_API_REGISTER api_register;
  tBTA_AG_API_OPEN api_open;
  tBTA_AG_API_RESULT api_result;
#if (BTM_WBS_INCLUDED == TRUE)
  tBTA_AG_API_SETCODEC api_setcodec;
#endif
  tBTA_AG_DISC_RESULT disc_result;
  tBTA_AG_RFC rfc;
  tBTA_AG_CI_RX_WRITE ci_rx_write;
@@ -213,12 +209,10 @@ typedef struct {
  uint8_t scn;
} tBTA_AG_PROFILE;

#if (BTM_WBS_INCLUDED == TRUE)
typedef enum {
  BTA_AG_SCO_MSBC_SETTINGS_T2 = 0, /* preferred/default when codec is mSBC */
  BTA_AG_SCO_MSBC_SETTINGS_T1,
} tBTA_AG_SCO_MSBC_SETTINGS;
#endif

/* type for each service control block */
typedef struct {
@@ -262,19 +256,15 @@ typedef struct {
  uint32_t bia_masked_out;  /* indicators HF does not want us to send */
  alarm_t* collision_timer;
  alarm_t* ring_timer;
#if (BTM_WBS_INCLUDED == TRUE)
  alarm_t* codec_negotiation_timer;
  tBTA_AG_PEER_CODEC peer_codecs; /* codecs for eSCO supported by the peer */
  tBTA_AG_PEER_CODEC sco_codec;   /* codec to be used for eSCO connection */
#endif
  tBTA_AG_PEER_CODEC
      inuse_codec;     /* codec being used for the current SCO connection */
#if (BTM_WBS_INCLUDED == TRUE)
  bool codec_updated;  /* set to true whenever the app updates codec type */
  bool codec_fallback; /* If sco nego fails for mSBC, fallback to CVSD */
  tBTA_AG_SCO_MSBC_SETTINGS
      codec_msbc_settings; /* settings to be used for the impending eSCO */
#endif

  tBTA_AG_HF_IND
      peer_hf_indicators[BTA_AG_MAX_NUM_PEER_HF_IND]; /* Peer supported
@@ -395,10 +385,8 @@ extern void bta_ag_sco_open(tBTA_AG_SCB* p_scb, tBTA_AG_DATA* p_data);
extern void bta_ag_ci_sco_open_continue(tBTA_AG_SCB* p_scb,
                                        tBTA_AG_DATA* p_data);
extern void bta_ag_sco_close(tBTA_AG_SCB* p_scb, tBTA_AG_DATA* p_data);
#if (BTM_WBS_INCLUDED == TRUE)
extern void bta_ag_sco_codec_nego(tBTA_AG_SCB* p_scb, bool result);
extern void bta_ag_codec_negotiate(tBTA_AG_SCB* p_scb);
#endif
extern void bta_ag_sco_shutdown(tBTA_AG_SCB* p_scb, tBTA_AG_DATA* p_data);
extern void bta_ag_sco_conn_open(tBTA_AG_SCB* p_scb, tBTA_AG_DATA* p_data);
extern void bta_ag_sco_conn_close(tBTA_AG_SCB* p_scb, tBTA_AG_DATA* p_data);
@@ -407,9 +395,7 @@ extern void bta_ag_post_sco_close(tBTA_AG_SCB* p_scb, tBTA_AG_DATA* p_data);
extern void bta_ag_svc_conn_open(tBTA_AG_SCB* p_scb, tBTA_AG_DATA* p_data);
extern void bta_ag_result(tBTA_AG_SCB* p_scb, tBTA_AG_DATA* p_data);
extern void bta_ag_setcodec(tBTA_AG_SCB* p_scb, tBTA_AG_DATA* p_data);
#if (BTM_WBS_INCLUDED == TRUE)
extern void bta_ag_send_bcs(tBTA_AG_SCB* p_scb, tBTA_AG_DATA* p_data);
#endif
extern void bta_ag_send_ring(tBTA_AG_SCB* p_scb, tBTA_AG_DATA* p_data);
extern void bta_ag_ci_sco_data(tBTA_AG_SCB* p_scb, tBTA_AG_DATA* p_data);
extern void bta_ag_ci_rx_data(tBTA_AG_SCB* p_scb, tBTA_AG_DATA* p_data);
+0 −8
Original line number Diff line number Diff line
@@ -274,20 +274,16 @@ static tBTA_AG_SCB* bta_ag_scb_alloc(void) {
      /* initialize variables */
      p_scb->in_use = true;
      p_scb->sco_idx = BTM_INVALID_SCO_INDEX;
#if (BTM_WBS_INCLUDED == TRUE)
      p_scb->codec_updated = false;
      p_scb->peer_codecs = BTA_AG_CODEC_CVSD;
      p_scb->sco_codec = BTA_AG_CODEC_CVSD;
#endif
      /* set up timers */
      p_scb->ring_timer = alarm_new("bta_ag.scb_ring_timer");
      p_scb->collision_timer = alarm_new("bta_ag.scb_collision_timer");
#if (BTM_WBS_INCLUDED == TRUE)
      p_scb->codec_negotiation_timer =
          alarm_new("bta_ag.scb_codec_negotiation_timer");
      /* set eSCO mSBC setting to T2 as the preferred */
      p_scb->codec_msbc_settings = BTA_AG_SCO_MSBC_SETTINGS_T2;
#endif
      APPL_TRACE_DEBUG("bta_ag_scb_alloc %d", bta_ag_scb_to_idx(p_scb));
      break;
    }
@@ -319,9 +315,7 @@ void bta_ag_scb_dealloc(tBTA_AG_SCB* p_scb) {

  /* stop and free timers */
  alarm_free(p_scb->ring_timer);
#if (BTM_WBS_INCLUDED == TRUE)
  alarm_free(p_scb->codec_negotiation_timer);
#endif
  alarm_free(p_scb->collision_timer);

  /* initialize control block */
@@ -609,9 +603,7 @@ static void bta_ag_api_enable(tBTA_AG_DATA* p_data) {
  /* initialize control block */
  for (size_t i = 0; i < BTA_AG_NUM_SCB; i++) {
    alarm_free(bta_ag_cb.scb[i].ring_timer);
#if (BTM_WBS_INCLUDED == TRUE)
    alarm_free(bta_ag_cb.scb[i].codec_negotiation_timer);
#endif
    alarm_free(bta_ag_cb.scb[i].collision_timer);
  }
  memset(&bta_ag_cb, 0, sizeof(tBTA_AG_CB));
+0 −106
Original line number Diff line number Diff line
@@ -64,10 +64,8 @@ enum {
  BTA_AG_SCO_OPEN_E,         /* open request */
  BTA_AG_SCO_OPEN_PENDING_E, /* Pending operations in open request */
  BTA_AG_SCO_XFER_E,         /* transfer request */
#if (BTM_WBS_INCLUDED == TRUE)
  BTA_AG_SCO_CN_DONE_E, /* codec negotiation done */
  BTA_AG_SCO_REOPEN_E,  /* Retry with other codec when failed */
#endif
  BTA_AG_SCO_CLOSE_E,      /* close request */
  BTA_AG_SCO_SHUTDOWN_E,   /* shutdown request */
  BTA_AG_SCO_CONN_OPEN_E,  /* sco open */
@@ -162,7 +160,6 @@ static void bta_ag_sco_disc_cback(uint16_t sco_idx) {
    bta_dm_sco_co_close();
#endif

#if (BTM_WBS_INCLUDED == TRUE)
    /* Restore settings */
    if (bta_ag_cb.sco.p_curr_scb->inuse_codec == BTA_AG_CODEC_MSBC) {
      /* Bypass vendor specific and voice settings if enhanced eSCO supported */
@@ -188,7 +185,6 @@ static void bta_ag_sco_disc_cback(uint16_t sco_idx) {
    }

    bta_ag_cb.sco.p_curr_scb->inuse_codec = BTA_AG_CODEC_NONE;
#endif

    BT_HDR* p_buf = (BT_HDR*)osi_malloc(sizeof(BT_HDR));
    p_buf->event = BTA_AG_SCO_CLOSE_EVT;
@@ -378,7 +374,6 @@ static void bta_ag_create_sco(tBTA_AG_SCB* p_scb, bool is_orig) {
                   controller_get_interface()
                       ->supports_enhanced_setup_synchronous_connection());

#if (BTM_WBS_INCLUDED == TRUE)
  if ((p_scb->sco_codec == BTA_AG_CODEC_MSBC) && !p_scb->codec_fallback &&
      !p_scb->retry_with_sco_only)
    esco_codec = BTA_AG_CODEC_MSBC;
@@ -416,21 +411,6 @@ static void bta_ag_create_sco(tBTA_AG_SCB* p_scb, bool is_orig) {
      params.retransmission_effort = ESCO_RETRANSMISSION_POWER;
    }
  }
#else
  /* When WBS is not included, use CVSD by default */
  params = esco_parameters_for_codec(ESCO_CODEC_CVSD);

  /* Use the applicable packet types (3-EV3 is not allowed according to errata
   * 2363) */
  params.packet_types =
      p_bta_ag_cfg->sco_pkt_types | ESCO_PKT_TYPES_MASK_NO_3_EV3;
  if ((!(p_scb->features & BTA_AG_FEAT_ESCO)) ||
      (!(p_scb->peer_features & BTA_AG_PEER_FEAT_ESCO))) {
    params.max_latency_ms = 10;
    params.retransmission_effort = ESCO_RETRANSMISSION_POWER;
  }

#endif

  /* if initiating set current scb and peer bd addr */
  if (is_orig) {
@@ -445,7 +425,6 @@ static void bta_ag_create_sco(tBTA_AG_SCB* p_scb, bool is_orig) {
          !((params.packet_types &
             ~(BTM_ESCO_LINK_ONLY_MASK | BTM_SCO_LINK_ONLY_MASK)) ^
            BTA_AG_NO_EDR_ESCO)) {
#if (BTM_WBS_INCLUDED == TRUE)
        if (esco_codec != BTA_AG_CODEC_MSBC) {
          p_scb->retry_with_sco_only = true;
          APPL_TRACE_API("Setting retry_with_sco_only to TRUE");
@@ -454,10 +433,6 @@ static void bta_ag_create_sco(tBTA_AG_SCB* p_scb, bool is_orig) {
          p_scb->retry_with_sco_only = false;
          APPL_TRACE_API("Setting retry_with_sco_only to FALSE");
        }
#else
        p_scb->retry_with_sco_only = true;
        APPL_TRACE_API("Setting retry_with_sco_only to TRUE");
#endif
      }
    } else {
      if (p_scb->retry_with_sco_only) APPL_TRACE_API("retrying with SCO only");
@@ -474,17 +449,12 @@ static void bta_ag_create_sco(tBTA_AG_SCB* p_scb, bool is_orig) {
    /* tell sys to stop av if any */
    bta_sys_sco_use(BTA_ID_AG, p_scb->app_id, p_scb->peer_addr);

#if (BTM_WBS_INCLUDED == TRUE)
    /* Allow any platform specific pre-SCO set up to take place After the
       pre-SCO Vendor Specific commands are sent,bta_ag_ci_audio_open_continue
       call-in needs to be called by the app to continue with SCO connection
       creation */
    bta_ag_co_audio_state(bta_ag_scb_to_idx(p_scb), p_scb->app_id,
                          SCO_STATE_SETUP, esco_codec);
#else
    bta_ag_co_audio_state(bta_ag_scb_to_idx(p_scb), p_scb->app_id,
                          SCO_STATE_SETUP);
#endif
  } else {
    p_scb->retry_with_sco_only = false;
    p_bd_addr = p_scb->peer_addr;
@@ -523,11 +493,9 @@ static void bta_ag_create_pending_sco(tBTA_AG_SCB* p_scb, bool is_local) {
  if (is_local) {
    if (bta_ag_cb.sco.set_audio_status == BTA_AG_SUCCESS) {
      if (esco_codec == BTA_AG_CODEC_MSBC) {
#if (BTM_WBS_INCLUDED == TRUE)
        if (p_scb->codec_msbc_settings == BTA_AG_SCO_MSBC_SETTINGS_T2) {
          params = esco_parameters_for_codec(ESCO_CODEC_MSBC_T2);
        } else
#endif
          params = esco_parameters_for_codec(ESCO_CODEC_MSBC_T1);
      } else {
        params = esco_parameters_for_codec(ESCO_CODEC_CVSD);
@@ -538,7 +506,6 @@ static void bta_ag_create_pending_sco(tBTA_AG_SCB* p_scb, bool is_local) {
        }
      }

#if (BTM_WBS_INCLUDED == TRUE)
      /* Bypass vendor specific and voice settings if enhanced eSCO supported */
      if (!(controller_get_interface()
                ->supports_enhanced_setup_synchronous_connection())) {
@@ -547,7 +514,6 @@ static void bta_ag_create_pending_sco(tBTA_AG_SCB* p_scb, bool is_local) {
        else
          BTM_WriteVoiceSettings(BTM_VOICE_SETTING_CVSD);
      }
#endif

#if (BTM_SCO_HCI_INCLUDED == TRUE)
      /* initialize SCO setup, no voice setting for AG, data rate <==> sample
@@ -585,7 +551,6 @@ static void bta_ag_create_pending_sco(tBTA_AG_SCB* p_scb, bool is_local) {
  }
}

#if (BTM_WBS_INCLUDED == TRUE)
/*******************************************************************************
 *
 * Function         bta_ag_attempt_msbc_safe_settings
@@ -658,7 +623,6 @@ void bta_ag_codec_negotiate(tBTA_AG_SCB* p_scb) {
    bta_ag_sco_codec_nego(p_scb, true);
  }
}
#endif /* (BTM_WBS_INCLUDED == TRUE) */

/*******************************************************************************
 *
@@ -672,9 +636,7 @@ void bta_ag_codec_negotiate(tBTA_AG_SCB* p_scb) {
 ******************************************************************************/
static void bta_ag_sco_event(tBTA_AG_SCB* p_scb, uint8_t event) {
  tBTA_AG_SCO_CB* p_sco = &bta_ag_cb.sco;
#if (BTM_WBS_INCLUDED == TRUE)
  tBTA_AG_SCB* p_cn_scb = NULL; /* For codec negotiation */
#endif
#if (BTM_SCO_HCI_INCLUDED == TRUE)
  BT_HDR* p_buf;
#endif
@@ -740,15 +702,9 @@ static void bta_ag_sco_event(tBTA_AG_SCB* p_scb, uint8_t event) {
          /* remove listening connection */
          bta_ag_remove_sco(p_scb, false);

#if (BTM_WBS_INCLUDED == TRUE)
          /* start codec negotiation */
          p_sco->state = BTA_AG_SCO_CODEC_ST;
          p_cn_scb = p_scb;
#else
          /* create sco connection to peer */
          bta_ag_create_sco(p_scb, true);
          p_sco->state = BTA_AG_SCO_OPENING_ST;
#endif
          break;

        case BTA_AG_SCO_SHUTDOWN_E:
@@ -784,7 +740,6 @@ static void bta_ag_sco_event(tBTA_AG_SCB* p_scb, uint8_t event) {
      }
      break;

#if (BTM_WBS_INCLUDED == TRUE)
    case BTA_AG_SCO_CODEC_ST:
      switch (event) {
        case BTA_AG_SCO_LISTEN_E:
@@ -833,7 +788,6 @@ static void bta_ag_sco_event(tBTA_AG_SCB* p_scb, uint8_t event) {
          break;
      }
      break;
#endif

    case BTA_AG_SCO_OPENING_ST:
      switch (event) {
@@ -845,13 +799,11 @@ static void bta_ag_sco_event(tBTA_AG_SCB* p_scb, uint8_t event) {
          }
          break;

#if (BTM_WBS_INCLUDED == TRUE)
        case BTA_AG_SCO_REOPEN_E:
          /* start codec negotiation */
          p_sco->state = BTA_AG_SCO_CODEC_ST;
          p_cn_scb = p_scb;
          break;
#endif

        case BTA_AG_SCO_OPEN_PENDING_E:
          /* Send pending commands to create SCO connection to peer */
@@ -1079,15 +1031,9 @@ static void bta_ag_sco_event(tBTA_AG_SCB* p_scb, uint8_t event) {
          break;

        case BTA_AG_SCO_CONN_CLOSE_E:
#if (BTM_WBS_INCLUDED == TRUE)
          /* start codec negotiation */
          p_sco->state = BTA_AG_SCO_CODEC_ST;
          p_cn_scb = p_scb;
#else
          /* open sco connection */
          bta_ag_create_sco(p_scb, true);
          p_sco->state = BTA_AG_SCO_OPENING_ST;
#endif
          break;

        case BTA_AG_SCO_LISTEN_E:
@@ -1133,17 +1079,10 @@ static void bta_ag_sco_event(tBTA_AG_SCB* p_scb, uint8_t event) {
          bta_ag_create_sco(p_scb, false);
          bta_ag_remove_sco(p_sco->p_xfer_scb, false);

#if (BTM_WBS_INCLUDED == TRUE)
          /* start codec negotiation */
          p_sco->state = BTA_AG_SCO_CODEC_ST;
          p_cn_scb = p_sco->p_xfer_scb;
          p_sco->p_xfer_scb = NULL;
#else
          /* create sco connection to peer */
          bta_ag_create_sco(p_sco->p_xfer_scb, true);
          p_sco->p_xfer_scb = NULL;
          p_sco->state = BTA_AG_SCO_OPENING_ST;
#endif
          break;

        default:
@@ -1222,11 +1161,9 @@ static void bta_ag_sco_event(tBTA_AG_SCB* p_scb, uint8_t event) {
  }
#endif

#if (BTM_WBS_INCLUDED == TRUE)
  if (p_cn_scb) {
    bta_ag_codec_negotiate(p_cn_scb);
  }
#endif
}

/*******************************************************************************
@@ -1332,22 +1269,16 @@ void bta_ag_ci_sco_open_continue(tBTA_AG_SCB* p_scb, tBTA_AG_DATA* p_data) {
 ******************************************************************************/
void bta_ag_sco_close(tBTA_AG_SCB* p_scb, UNUSED_ATTR tBTA_AG_DATA* p_data) {
/* if scb is in use */
#if (BTM_WBS_INCLUDED == TRUE)
  /* sco_idx is not allocated in SCO_CODEC_ST, still need to move to listen
   * state. */
  if ((p_scb->sco_idx != BTM_INVALID_SCO_INDEX) ||
      (bta_ag_cb.sco.state == BTA_AG_SCO_CODEC_ST))
#else
  if (p_scb->sco_idx != BTM_INVALID_SCO_INDEX)
#endif
  {
    APPL_TRACE_DEBUG("bta_ag_sco_close: sco_inx = %d", p_scb->sco_idx);
    bta_ag_sco_event(p_scb, BTA_AG_SCO_CLOSE_E);
  }
}

#if (BTM_WBS_INCLUDED == TRUE)

/*******************************************************************************
 *
 * Function         bta_ag_sco_codec_nego
@@ -1367,7 +1298,6 @@ void bta_ag_sco_codec_nego(tBTA_AG_SCB* p_scb, bool result) {
  } else /* codec negotiation failed */
    bta_ag_sco_event(p_scb, BTA_AG_SCO_CLOSE_E);
}
#endif

/*******************************************************************************
 *
@@ -1399,12 +1329,8 @@ void bta_ag_sco_conn_open(tBTA_AG_SCB* p_scb,

  bta_sys_sco_open(BTA_ID_AG, p_scb->app_id, p_scb->peer_addr);

#if (BTM_WBS_INCLUDED == TRUE)
  bta_ag_co_audio_state(bta_ag_scb_to_idx(p_scb), p_scb->app_id, SCO_STATE_ON,
                        p_scb->inuse_codec);
#else
  bta_ag_co_audio_state(bta_ag_scb_to_idx(p_scb), p_scb->app_id, SCO_STATE_ON);
#endif

#if (BTM_SCO_HCI_INCLUDED == TRUE)
  /* open SCO codec if SCO is routed through transport */
@@ -1416,10 +1342,8 @@ void bta_ag_sco_conn_open(tBTA_AG_SCB* p_scb,
  bta_ag_cback_sco(p_scb, BTA_AG_AUDIO_OPEN_EVT);

  p_scb->retry_with_sco_only = false;
#if (BTM_WBS_INCLUDED == TRUE)
  /* reset to mSBC T2 settings as the preferred */
  p_scb->codec_msbc_settings = BTA_AG_SCO_MSBC_SETTINGS_T2;
#endif
}

/*******************************************************************************
@@ -1440,7 +1364,6 @@ void bta_ag_sco_conn_close(tBTA_AG_SCB* p_scb,
  bta_ag_cb.sco.p_curr_scb = NULL;
  p_scb->sco_idx = BTM_INVALID_SCO_INDEX;

#if (BTM_WBS_INCLUDED == TRUE)
  /* codec_fallback is set when AG is initiator and connection failed for mSBC.
   */
  /* OR if codec is msbc and T2 settings failed, then retry Safe T1 settings */
@@ -1452,23 +1375,11 @@ void bta_ag_sco_conn_close(tBTA_AG_SCB* p_scb,
     * eSCO */
    bta_ag_create_sco(p_scb, true);
  }
#else
  /* retry_with_sco_only, will be set only when AG is initiator
  ** and AG is first trying to establish an eSCO connection */
  if (p_scb->retry_with_sco_only && p_scb->svc_conn) {
    bta_ag_create_sco(p_scb, true);
  }
#endif
  else {
    sco_state_t sco_state =
        bta_ag_cb.sco.p_xfer_scb ? SCO_STATE_OFF_TRANSFER : SCO_STATE_OFF;
#if (BTM_WBS_INCLUDED == TRUE)
    /* Indicate if the closing of audio is because of transfer */
    bta_ag_co_audio_state(handle, p_scb->app_id, sco_state, p_scb->inuse_codec);
#else
    /* Indicate if the closing of audio is because of transfer */
    bta_ag_co_audio_state(handle, p_scb->app_id, sco_state);
#endif
    bta_ag_sco_event(p_scb, BTA_AG_SCO_CONN_CLOSE_E);

    bta_sys_sco_close(BTA_ID_AG, p_scb->app_id, p_scb->peer_addr);
@@ -1483,9 +1394,7 @@ void bta_ag_sco_conn_close(tBTA_AG_SCB* p_scb,

    /* call app callback */
    bta_ag_cback_sco(p_scb, BTA_AG_AUDIO_CLOSE_EVT);
#if (BTM_WBS_INCLUDED == TRUE)
    p_scb->codec_msbc_settings = BTA_AG_SCO_MSBC_SETTINGS_T2;
#endif
  }
  p_scb->retry_with_sco_only = false;
}
@@ -1513,19 +1422,10 @@ void bta_ag_sco_conn_rsp(tBTA_AG_SCB* p_scb,
      bta_ag_cb.sco.state == BTA_AG_SCO_OPEN_XFER_ST) {
    /* tell sys to stop av if any */
    bta_sys_sco_use(BTA_ID_AG, p_scb->app_id, p_scb->peer_addr);
#if (BTM_WBS_INCLUDED == FALSE)
    /* Allow any platform specific pre-SCO set up to take place After the
       pre-SCO Vendor Specific commands are sent, bta_ag_ci_audio_open_continue
       call-in needs to be called by the app to continue with SCO accept/reject
       HCI commands*/
    bta_ag_co_audio_state(bta_ag_scb_to_idx(p_scb), p_scb->app_id,
                          SCO_STATE_SETUP);
#else
    /* When HS initiated SCO, it cannot be WBS. */
    /* Allow any platform specific pre-SCO set up to take place */
    bta_ag_co_audio_state(bta_ag_scb_to_idx(p_scb), p_scb->app_id,
                          SCO_STATE_SETUP, BTA_AG_CODEC_CVSD);
#endif

#if (BTM_SCO_HCI_INCLUDED == TRUE)
    /* Configure the transport being used */
@@ -1533,10 +1433,8 @@ void bta_ag_sco_conn_rsp(tBTA_AG_SCB* p_scb,
#endif
  }

#if (BTM_WBS_INCLUDED == TRUE)
  /* If SCO open was initiated from HS, it must be CVSD */
  p_scb->inuse_codec = BTA_AG_CODEC_NONE;
#endif
}

/*******************************************************************************
@@ -1571,12 +1469,10 @@ static char* bta_ag_sco_evt_str(uint8_t event) {
      return "Open pending request";
    case BTA_AG_SCO_XFER_E:
      return "Transfer Request";
#if (BTM_WBS_INCLUDED == TRUE)
    case BTA_AG_SCO_CN_DONE_E:
      return "Codec Negotiation Done";
    case BTA_AG_SCO_REOPEN_E:
      return "Reopen Request";
#endif
    case BTA_AG_SCO_CLOSE_E:
      return "Close Request";
    case BTA_AG_SCO_SHUTDOWN_E:
@@ -1598,10 +1494,8 @@ static char* bta_ag_sco_state_str(uint8_t state) {
      return "Shutdown";
    case BTA_AG_SCO_LISTEN_ST:
      return "Listening";
#if (BTM_WBS_INCLUDED == TRUE)
    case BTA_AG_SCO_CODEC_ST:
      return "Codec Negotiation";
#endif
    case BTA_AG_SCO_OPENING_ST:
      return "Opening";
    case BTA_AG_SCO_OPEN_CL_ST:
Loading