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

Commit f35d44a8 authored by android-build-team Robot's avatar android-build-team Robot
Browse files

Snap for 7419753 from e922d900 to sc-release

Change-Id: Ia30c2065b90702903f5ad4de796c6fc04e22526b
parents 51359f22 e922d900
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -341,8 +341,12 @@ static int out_set_parameters(struct audio_stream* stream,
    if (params["A2dpSuspended"] == "true") {
      LOG(INFO) << __func__ << ": state=" << out->bluetooth_output_.GetState()
                << " stream param stopped";
      if (out->bluetooth_output_.GetState() != BluetoothStreamState::DISABLED) {
      out->frames_rendered_ = 0;
      if (out->bluetooth_output_.GetState() == BluetoothStreamState::STARTED) {
        out->bluetooth_output_.Suspend();
        out->bluetooth_output_.SetState(BluetoothStreamState::DISABLED);
      } else if (out->bluetooth_output_.GetState() !=
                 BluetoothStreamState::DISABLED) {
        out->bluetooth_output_.Stop();
      }
    } else {
@@ -498,6 +502,10 @@ static ssize_t out_write(struct audio_stream_out* stream, const void* buffer,
    if (stream->resume(stream)) {
      LOG(ERROR) << __func__ << ": state=" << out->bluetooth_output_.GetState()
                 << " failed to resume";
      if (out->bluetooth_output_.GetState() == BluetoothStreamState::DISABLED) {
        // drop data for cases of A2dpSuspended=true / closing=true
        totalWritten = bytes;
      }
      usleep(kBluetoothDefaultOutputBufferMs * 1000);
      return totalWritten;
    }
+7 −4
Original line number Diff line number Diff line
@@ -860,6 +860,8 @@ void bta_av_cleanup(tBTA_AV_SCB* p_scb, UNUSED_ATTR tBTA_AV_DATA* p_data) {
  p_scb->num_disc_snks = 0;
  p_scb->coll_mask = 0;
  alarm_cancel(p_scb->avrc_ct_timer);
  alarm_cancel(p_scb->link_signalling_timer);
  alarm_cancel(p_scb->accept_signalling_timer);

  /* TODO(eisenbach): RE-IMPLEMENT USING VSC OR HAL EXTENSION
    vendor_get_interface()->send_command(
@@ -935,7 +937,7 @@ void bta_av_config_ind(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {

  /* Clear collision mask */
  p_scb->coll_mask = 0;
  alarm_cancel(bta_av_cb.accept_signalling_timer);
  alarm_cancel(p_scb->accept_signalling_timer);

  /* if no codec parameters in configuration, fail */
  if ((p_evt_cfg->num_codec == 0) ||
@@ -1001,7 +1003,8 @@ void bta_av_disconnect_req(tBTA_AV_SCB* p_scb,
  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->link_signalling_timer);
  alarm_cancel(p_scb->accept_signalling_timer);
  alarm_cancel(p_scb->avrc_ct_timer);

  // conn_lcb is the index bitmask of all used LCBs, and since LCB and SCB use
@@ -1091,7 +1094,7 @@ void bta_av_setconfig_rsp(tBTA_AV_SCB* p_scb, tBTA_AV_DATA* p_data) {
  AVDT_ConfigRsp(p_scb->avdt_handle, p_scb->avdt_label,
                 p_data->ci_setconfig.err_code, p_data->ci_setconfig.category);

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

  if (p_data->ci_setconfig.err_code == AVDT_SUCCESS) {
    p_scb->wait = BTA_AV_WAIT_ACP_CAPS_ON;
@@ -1316,7 +1319,7 @@ void bta_av_do_close(tBTA_AV_SCB* p_scb, UNUSED_ATTR tBTA_AV_DATA* p_data) {
  if (p_scb->co_started) {
    bta_av_str_stopped(p_scb, NULL);
  }
  alarm_cancel(bta_av_cb.link_signalling_timer);
  alarm_cancel(p_scb->link_signalling_timer);

  /* close stream */
  p_scb->started = false;
+29 −12
Original line number Diff line number Diff line
@@ -1305,6 +1305,12 @@ void bta_av_disable(tBTA_AV_CB* p_cb, UNUSED_ATTR tBTA_AV_DATA* p_data) {
   * expect BTA_AV_DEREG_COMP_EVT when deregister is complete */
  for (xx = 0; xx < BTA_AV_NUM_STRS; xx++) {
    if (p_cb->p_scb[xx] != NULL) {
      // Free signalling timers
      alarm_free(p_cb->p_scb[xx]->link_signalling_timer);
      p_cb->p_scb[xx]->link_signalling_timer = NULL;
      alarm_free(p_cb->p_scb[xx]->accept_signalling_timer);
      p_cb->p_scb[xx]->accept_signalling_timer = NULL;

      hdr.layer_specific = xx + 1;
      bta_av_api_deregister((tBTA_AV_DATA*)&hdr);
      disabling_in_progress = true;
@@ -1315,10 +1321,6 @@ void bta_av_disable(tBTA_AV_CB* p_cb, UNUSED_ATTR tBTA_AV_DATA* p_data) {
  // no needed to setup this disabling flag.
  p_cb->disabling = disabling_in_progress;

  alarm_free(p_cb->link_signalling_timer);
  p_cb->link_signalling_timer = NULL;
  alarm_free(p_cb->accept_signalling_timer);
  p_cb->accept_signalling_timer = NULL;
}

/*******************************************************************************
@@ -1331,8 +1333,10 @@ void bta_av_disable(tBTA_AV_CB* p_cb, UNUSED_ATTR tBTA_AV_DATA* p_data) {
 *
 ******************************************************************************/
void bta_av_api_disconnect(tBTA_AV_DATA* p_data) {
  AVDT_DisconnectReq(p_data->api_discnt.bd_addr, bta_av_conn_cback);
  alarm_cancel(bta_av_cb.link_signalling_timer);
  tBTA_AV_SCB* p_scb =
      bta_av_hndl_to_scb(p_data->api_discnt.hdr.layer_specific);
  AVDT_DisconnectReq(p_scb->PeerAddress(), bta_av_conn_cback);
  alarm_cancel(p_scb->link_signalling_timer);
}

/**
@@ -1450,21 +1454,30 @@ void bta_av_sig_chg(tBTA_AV_DATA* p_data) {
         * The following function shall send the event and start the
         * recurring timer
         */
        bta_av_signalling_timer(NULL);
        if (!p_scb->link_signalling_timer) {
          p_scb->link_signalling_timer = alarm_new("link_signalling_timer");
        }
        BT_HDR hdr;
        hdr.layer_specific = p_scb->hndl;
        bta_av_signalling_timer((tBTA_AV_DATA*)&hdr);

        APPL_TRACE_DEBUG("%s: Re-start timer for AVDTP service", __func__);
        bta_sys_conn_open(BTA_ID_AV, p_scb->app_id, p_scb->PeerAddress());
        /* Possible collision : need to avoid outgoing processing while the
         * timer is running */
        p_scb->coll_mask = BTA_AV_COLL_INC_TMR;
        if (!p_scb->accept_signalling_timer) {
          p_scb->accept_signalling_timer = alarm_new("accept_signalling_timer");
        }
        alarm_set_on_mloop(
            p_cb->accept_signalling_timer, BTA_AV_ACCEPT_SIGNALLING_TIMEOUT_MS,
            p_scb->accept_signalling_timer, BTA_AV_ACCEPT_SIGNALLING_TIMEOUT_MS,
            bta_av_accept_signalling_timer_cback, UINT_TO_PTR(xx));
      }
    }
  }
  else if (event == BTA_AR_AVDT_CONN_EVT) {
    alarm_cancel(bta_av_cb.link_signalling_timer);
    uint8_t scb_index = p_data->str_msg.scb_index;
    alarm_cancel(p_cb->p_scb[scb_index]->link_signalling_timer);
  }
  else {
    /* disconnected. */
@@ -1511,6 +1524,9 @@ void bta_av_sig_chg(tBTA_AV_DATA* p_data) {
 *
 ******************************************************************************/
void bta_av_signalling_timer(UNUSED_ATTR tBTA_AV_DATA* p_data) {
  tBTA_AV_HNDL hndl = p_data->hdr.layer_specific;
  tBTA_AV_SCB* p_scb = bta_av_hndl_to_scb(hndl);

  tBTA_AV_CB* p_cb = &bta_av_cb;
  int xx;
  uint8_t mask;
@@ -1527,9 +1543,10 @@ void bta_av_signalling_timer(UNUSED_ATTR tBTA_AV_DATA* p_data) {
    if (mask & p_cb->conn_lcb) {
      /* this entry is used. check if it is connected */
      if (!p_lcb->conn_msk) {
        bta_sys_start_timer(p_cb->link_signalling_timer,
        APPL_TRACE_DEBUG("%s hndl 0x%x", __func__, p_scb->hndl);
        bta_sys_start_timer(p_scb->link_signalling_timer,
                            BTA_AV_SIGNALLING_TIMEOUT_MS,
                            BTA_AV_SIGNALLING_TIMER_EVT, 0);
                            BTA_AV_SIGNALLING_TIMER_EVT, hndl);
        tBTA_AV_PEND pend;
        pend.bd_addr = p_lcb->addr;
        tBTA_AV bta_av_data;
@@ -1574,7 +1591,7 @@ static void bta_av_accept_signalling_timer_cback(void* data) {
          /* We are still doing SDP. Run the timer again. */
          p_scb->coll_mask |= BTA_AV_COLL_INC_TMR;

          alarm_set_on_mloop(p_cb->accept_signalling_timer,
          alarm_set_on_mloop(p_scb->accept_signalling_timer,
                             BTA_AV_ACCEPT_SIGNALLING_TIMEOUT_MS,
                             bta_av_accept_signalling_timer_cback,
                             UINT_TO_PTR(inx));
+3 −3
Original line number Diff line number Diff line
@@ -193,14 +193,14 @@ void BTA_AvClose(tBTA_AV_HNDL handle) {
 * Returns          void
 *
 ******************************************************************************/
void BTA_AvDisconnect(const RawAddress& bd_addr) {
  LOG_INFO("%s: peer %s", __func__, bd_addr.ToString().c_str());
void BTA_AvDisconnect(tBTA_AV_HNDL handle) {
  LOG_INFO("%s: bta_handle=0x%x", __func__, handle);

  tBTA_AV_API_DISCNT* p_buf =
      (tBTA_AV_API_DISCNT*)osi_malloc(sizeof(tBTA_AV_API_DISCNT));

  p_buf->hdr.event = BTA_AV_API_DISCONNECT_EVT;
  p_buf->bd_addr = bd_addr;
  p_buf->hdr.layer_specific = handle;

  bta_sys_sendmsg(p_buf);
}
+3 −4
Original line number Diff line number Diff line
@@ -272,7 +272,6 @@ typedef struct {
/* data type for BTA_AV_API_DISCONNECT_EVT */
typedef struct {
  BT_HDR_RIGID hdr;
  RawAddress bd_addr;
} tBTA_AV_API_DISCNT;

/* data type for BTA_AV_API_PROTECT_REQ_EVT */
@@ -491,6 +490,9 @@ struct tBTA_AV_SCB final {
  tAVDT_SEP_INFO sep_info[BTA_AV_NUM_SEPS]; /* stream discovery results */
  AvdtpSepConfig cfg;                       /* local SEP configuration */
  alarm_t* avrc_ct_timer;                   /* delay timer for AVRC CT */
  alarm_t* link_signalling_timer;
  alarm_t*
      accept_signalling_timer; /* timer to monitor signalling when accepting */
  uint16_t l2c_cid;                         /* L2CAP channel ID */
  uint16_t stream_mtu;                      /* MTU of stream */
  uint8_t media_type;         /* Media type: AVDT_MEDIA_TYPE_* */
@@ -616,9 +618,6 @@ typedef struct {
  tBTA_AV_CBACK* p_cback;                /* application callback function */
  tBTA_AV_RCB rcb[BTA_AV_NUM_RCB];       /* RCB control block */
  tBTA_AV_LCB lcb[BTA_AV_NUM_LINKS + 1]; /* link control block */
  alarm_t* link_signalling_timer;
  alarm_t*
      accept_signalling_timer;  /* timer to monitor signalling when accepting */
  uint32_t sdp_a2dp_handle;     /* SDP record handle for audio src */
  uint32_t sdp_a2dp_snk_handle; /* SDP record handle for audio snk */
  tBTA_AV_FEAT features;        /* features mask */
Loading