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

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

Snap for 5626642 from df13cf2b to qt-c2f2-release

Change-Id: I0a496fbc1f8e0af327f63e3455067d8ef167d633
parents ef65d6c1 df13cf2b
Loading
Loading
Loading
Loading
+3 −8
Original line number Diff line number Diff line
@@ -172,7 +172,8 @@ class BluetoothAudioDeathRecipient
      // restart the session on the correct thread
      message_loop_->DoInThread(
          FROM_HERE,
          base::BindOnce(&RenewAudioProviderAndSession,
          base::BindOnce(
              &BluetoothAudioClientInterface::RenewAudioProviderAndSession,
              base::Unretained(bluetooth_audio_clientif_)));
    } else {
      LOG(ERROR) << __func__ << ": BluetoothAudioClientInterface corrupted";
@@ -182,12 +183,6 @@ class BluetoothAudioDeathRecipient
 private:
  BluetoothAudioClientInterface* bluetooth_audio_clientif_;
  bluetooth::common::MessageLoopThread* message_loop_;
  static void RenewAudioProviderAndSession(
      BluetoothAudioClientInterface* bluetooth_audio_clientif) {
    if (bluetooth_audio_clientif != nullptr) {
      bluetooth_audio_clientif->RenewAudioProviderAndSession();
    }
  }
};

BluetoothAudioClientInterface::BluetoothAudioClientInterface(IBluetoothTransportInstance* sink,
+5 −5
Original line number Diff line number Diff line
@@ -68,12 +68,12 @@ class HearingAidTransport

  void StopRequest() override {
    LOG(INFO) << __func__;
    stream_cb_.on_suspend_();

    if (stream_cb_.on_suspend_()) {
      // flush
      uint8_t p_buf[AUDIO_STREAM_OUTPUT_BUFFER_SZ * 2];
      ::bluetooth::audio::hearing_aid::read(p_buf, sizeof(p_buf));
    }
  }

  bool GetPresentationPosition(uint64_t* remote_delay_report_ns,
                               uint64_t* total_bytes_read,
+14 −15
Original line number Diff line number Diff line
@@ -1240,22 +1240,12 @@ void bta_gattc_process_indicate(uint16_t conn_id, tGATTC_OPTYPE op,
  }

  tBTA_GATTC_CLCB* p_clcb = bta_gattc_find_clcb_by_conn_id(conn_id);

  notify.handle = handle;

  /* if service change indication/notification, don't forward to application */
  if (bta_gattc_process_srvc_chg_ind(conn_id, p_clrcb, p_srcb, p_clcb, &notify,
                                     &p_data->att_value))
    return;

  /* if app registered for the notification */
  if (bta_gattc_check_notif_registry(p_clrcb, p_srcb, &notify)) {
  /* connection not open yet */
  if (p_clcb == NULL) {
    p_clcb = bta_gattc_clcb_alloc(gatt_if, remote_bda, transport);

    if (p_clcb == NULL) {
        LOG(ERROR) << "No resources";
      LOG(ERROR) << __func__ << ": No resources";
      return;
    }

@@ -1265,6 +1255,15 @@ void bta_gattc_process_indicate(uint16_t conn_id, tGATTC_OPTYPE op,
    bta_gattc_sm_execute(p_clcb, BTA_GATTC_INT_CONN_EVT, NULL);
  }

  notify.handle = handle;

  /* if service change indication/notification, don't forward to application */
  if (bta_gattc_process_srvc_chg_ind(conn_id, p_clrcb, p_srcb, p_clcb, &notify,
                                     &p_data->att_value))
    return;

  /* if app registered for the notification */
  if (bta_gattc_check_notif_registry(p_clrcb, p_srcb, &notify)) {
    if (p_clcb != NULL)
      bta_gattc_proc_other_indication(p_clcb, op, p_data, &notify);
  }
+13 −7
Original line number Diff line number Diff line
@@ -38,8 +38,8 @@ int sample_rate = -1;
int data_interval_ms = -1;
int num_channels = 2;
bluetooth::common::RepeatingTimer audio_timer;
HearingAidAudioReceiver* localAudioReceiver;
std::unique_ptr<tUIPC_STATE> uipc_hearing_aid;
HearingAidAudioReceiver* localAudioReceiver = nullptr;
std::unique_ptr<tUIPC_STATE> uipc_hearing_aid = nullptr;

struct AudioHalStats {
  size_t media_read_total_underflow_bytes;
@@ -85,8 +85,10 @@ void send_audio_data() {

  std::vector<uint8_t> data(p_buf, p_buf + bytes_read);

  if (localAudioReceiver != nullptr) {
    localAudioReceiver->OnAudioDataReady(data);
  }
}

void hearing_aid_send_ack(tHEARING_AID_CTRL_ACK status) {
  uint8_t ack = status;
@@ -305,7 +307,7 @@ void hearing_aid_ctrl_cb(tUIPC_CH_ID, tUIPC_EVENT event) {

bool hearing_aid_on_resume_req(bool start_media_task) {
  // hearing_aid_recv_ctrl_data(HEARING_AID_CTRL_CMD_START)
  if (localAudioReceiver) {
  if (localAudioReceiver != nullptr) {
    // Call OnAudioResume and block till it returns.
    std::promise<void> do_resume_promise;
    std::future<void> do_resume_future = do_resume_promise.get_future();
@@ -342,7 +344,7 @@ bool hearing_aid_on_resume_req(bool start_media_task) {
bool hearing_aid_on_suspend_req() {
  // hearing_aid_recv_ctrl_data(HEARING_AID_CTRL_CMD_SUSPEND): stop_media_task
  stop_audio_ticks();
  if (localAudioReceiver) {
  if (localAudioReceiver != nullptr) {
    // Call OnAudioSuspend and block till it returns.
    std::promise<void> do_suspend_promise;
    std::future<void> do_suspend_future = do_suspend_promise.get_future();
@@ -369,8 +371,7 @@ bool hearing_aid_on_suspend_req() {
void HearingAidAudioSource::Start(const CodecConfiguration& codecConfiguration,
                                  HearingAidAudioReceiver* audioReceiver,
                                  uint16_t remote_delay_ms) {
  localAudioReceiver = audioReceiver;
  VLOG(2) << "Hearing Aid UIPC Open";
  LOG(INFO) << __func__ << ": Hearing Aid Source Open";

  bit_rate = codecConfiguration.bit_rate;
  sample_rate = codecConfiguration.sample_rate;
@@ -382,9 +383,13 @@ void HearingAidAudioSource::Start(const CodecConfiguration& codecConfiguration,
    bluetooth::audio::hearing_aid::start_session();
    bluetooth::audio::hearing_aid::set_remote_delay(remote_delay_ms);
  }
  localAudioReceiver = audioReceiver;
}

void HearingAidAudioSource::Stop() {
  LOG(INFO) << __func__ << ": Hearing Aid Source Close";

  localAudioReceiver = nullptr;
  if (bluetooth::audio::hearing_aid::is_hal_2_0_enabled()) {
    bluetooth::audio::hearing_aid::end_session();
  }
@@ -409,6 +414,7 @@ void HearingAidAudioSource::CleanUp() {
    bluetooth::audio::hearing_aid::cleanup();
  } else {
    UIPC_Close(*uipc_hearing_aid, UIPC_CH_ID_ALL);
    uipc_hearing_aid = nullptr;
  }
}