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

Commit 226a9a1b authored by En-Shuo Hsu's avatar En-Shuo Hsu
Browse files

Use is_wbs() instead of checking coding_format

Also change some comments from // to /* */ that seems to be more
general.

Tag: #floss
Test: build
Bug: 235901463
Change-Id: Ib45b26917939c3df6520f5ac428e4dd99302363b
parent ea9fc3eb
Loading
Loading
Loading
Loading
+6 −11
Original line number Diff line number Diff line
@@ -75,8 +75,7 @@ const bluetooth::legacy::hci::Interface& GetLegacyHciInterface() {
#define BTM_ESCO_2_SCO(escotype) \
  ((uint16_t)(((escotype)&BTM_ESCO_PKT_TYPE_MASK) << 5))

/* Define masks for supported and exception 2.0 SCO packet types
 */
/* Define masks for supported and exception 2.0 SCO packet types */
#define BTM_SCO_SUPPORTED_PKTS_MASK                    \
  (ESCO_PKT_TYPES_MASK_HV1 | ESCO_PKT_TYPES_MASK_HV2 | \
   ESCO_PKT_TYPES_MASK_HV3 | ESCO_PKT_TYPES_MASK_EV3 | \
@@ -191,7 +190,7 @@ static void btm_esco_conn_rsp(uint16_t sco_inx, uint8_t hci_status,
  }
}

// Return the active (first connected) SCO connection block
/* Return the active (first connected) SCO connection block */
static tSCO_CONN* btm_get_active_sco() {
  for (auto& link : btm_cb.sco_cb.sco_db) {
    if (link.state == SCO_ST_CONNECTED) {
@@ -247,9 +246,8 @@ void btm_route_sco_data(BT_HDR* p_msg) {
    return;
  }

  if (active_sco->esco.setup.transmit_coding_format.coding_format ==
      ESCO_CODING_FORMAT_TRANSPNT /* Inband MSBC */) {
    // TODO(b/235901463): Support packet size != BTM_MSBC_PKT_LEN
  if (active_sco->is_wbs()) {
    /* TODO(b/235901463): Support packet size != BTM_MSBC_PKT_LEN */
    if (length != BTM_MSBC_PKT_LEN) {
      LOG_ERROR("Received invalid mSBC packet with invalid length:%hhu",
                length);
@@ -288,13 +286,10 @@ void btm_route_sco_data(BT_HDR* p_msg) {
  bluetooth::audio::sco::write(out_data, length);
  osi_free(p_msg);

  // For Chrome OS, we send the outgoing data after receiving an incoming one
  /* For Chrome OS, we send the outgoing data after receiving an incoming one */
  auto size_read = bluetooth::audio::sco::read(read_buf, length);

  if (active_sco->esco.setup.transmit_coding_format.coding_format ==
      ESCO_CODING_FORMAT_TRANSPNT /* Inband MSBC */) {
    /* The pre-computed zero input bit stream of mSBC codec, per HFP 1.7 spec.
     * This mSBC frame will be decoded into all-zero input PCM. */
  if (active_sco->is_wbs()) {
    uint8_t encoded[BTM_MSBC_PKT_LEN] = {
        BTM_MSBC_H2_HEADER_0,
        btm_h2_header_frames_count[btm_msbc_num_out_frames % 4]};
+10 −13
Original line number Diff line number Diff line
@@ -25,28 +25,26 @@

constexpr uint16_t kMaxScoLinks = static_cast<uint16_t>(BTM_MAX_SCO_LINKS);

// SCO-over-HCI audio related definitions
/* SCO-over-HCI audio related definitions */
namespace bluetooth::audio::sco {

// Initialize SCO-over-HCI socket (UIPC); the client is audio server.
/* Initialize SCO-over-HCI socket (UIPC); the client is audio server */
void init();

// Open the socket when there is SCO connection open
/* Open the socket when there is SCO connection open */
void open();

// Clean up the socket when the SCO connection is done
/* Clean up the socket when the SCO connection is done */
void cleanup();

// Read from the socket (audio server) for SCO Tx
/* Read from the socket (audio server) for SCO Tx */
size_t read(uint8_t* p_buf, uint32_t len);

// Write to the socket from SCO Rx
/* Write to the socket from SCO Rx */
size_t write(const uint8_t* buf, uint32_t len);
}  // namespace bluetooth::audio::sco

/* Define the structures needed by sco
 */

/* Define the structures needed by sco */
typedef enum : uint16_t {
  SCO_ST_UNUSED = 0,
  SCO_ST_LISTENING = 1,
@@ -90,8 +88,7 @@ typedef struct {
  uint8_t hci_status;
} tBTM_ESCO_INFO;

/* Define the structure used for SCO Management
 */
/* Define the structure used for SCO Management */
typedef struct {
  tBTM_ESCO_INFO esco;    /* Current settings             */
  tBTM_SCO_CB* p_conn_cb; /* Callback for when connected  */
@@ -161,8 +158,8 @@ typedef struct {
extern void btm_sco_chk_pend_rolechange(uint16_t hci_handle);
extern void btm_sco_disc_chk_pend_for_modechange(uint16_t hci_handle);

// Visible for test only
/* Visible for test only */
BT_HDR* btm_sco_make_packet(std::vector<uint8_t> data, uint16_t sco_handle);

// Send a SCO packet
/* Send a SCO packet */
void btm_send_sco_packet(std::vector<uint8_t> data);