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

Commit 38f46d4a authored by Pavlin Radoslavov's avatar Pavlin Radoslavov Committed by android-build-merger
Browse files

Merge "Reset a2dp_cmd_pending as appropriate for A2DP HW offload HAL commands"

am: f72bb8b1

Change-Id: I12094731788806e14e0cc57af3b239415e69770e
parents a82727f1 f72bb8b1
Loading
Loading
Loading
Loading
+14 −3
Original line number Diff line number Diff line
@@ -339,6 +339,9 @@ void btif_a2dp_audio_on_started(tBTA_AV_STATUS status) {
  LOG_INFO(LOG_TAG, "%s: status = %d", __func__, status);
  if (btAudio != nullptr) {
    if (a2dp_cmd_pending == A2DP_CTRL_CMD_START) {
      if (status != A2DP_CTRL_ACK_PENDING) {
        a2dp_cmd_pending = A2DP_CTRL_CMD_NONE;
      }
      LOG_INFO(LOG_TAG, "%s: calling method onStarted", __func__);
      auto hal_status = mapToStatus(status);
      btAudio->streamStarted(hal_status);
@@ -353,6 +356,9 @@ void btif_a2dp_audio_on_suspended(tBTA_AV_STATUS status) {
  LOG_INFO(LOG_TAG, "%s: status = %d", __func__, status);
  if (btAudio != nullptr) {
    if (a2dp_cmd_pending == A2DP_CTRL_CMD_SUSPEND) {
      if (status != A2DP_CTRL_ACK_PENDING) {
        a2dp_cmd_pending = A2DP_CTRL_CMD_NONE;
      }
      LOG_INFO(LOG_TAG, "calling method onSuspended");
      auto hal_status = mapToStatus(status);
      btAudio->streamSuspended(hal_status);
@@ -366,6 +372,7 @@ void btif_a2dp_audio_on_suspended(tBTA_AV_STATUS status) {
void btif_a2dp_audio_on_stopped(tBTA_AV_STATUS status) {
  LOG_INFO(LOG_TAG, "%s: status = %d", __func__, status);
  if (btAudio != nullptr && a2dp_cmd_pending == A2DP_CTRL_CMD_START) {
    a2dp_cmd_pending = A2DP_CTRL_CMD_NONE;
    LOG_INFO(LOG_TAG, "%s: Remote disconnected when start under progress",
             __func__);
    btAudio->streamStarted(mapToStatus(A2DP_CTRL_ACK_DISCONNECT_IN_PROGRESS));
@@ -418,7 +425,6 @@ void btif_a2dp_audio_send_stop_req() {
uint8_t btif_a2dp_audio_process_request(uint8_t cmd) {
  LOG_INFO(LOG_TAG, "%s: cmd: %s", __func__,
           audio_a2dp_hw_dump_ctrl_event((tA2DP_CTRL_CMD)cmd));
  a2dp_cmd_pending = cmd;
  uint8_t status;
  switch (cmd) {
    case A2DP_CTRL_CMD_START:
@@ -461,7 +467,7 @@ uint8_t btif_a2dp_audio_process_request(uint8_t cmd) {
      APPL_TRACE_WARNING("%s: A2DP command %s while AV stream is not ready",
                         __func__,
                         audio_a2dp_hw_dump_ctrl_event((tA2DP_CTRL_CMD)cmd));
      return A2DP_CTRL_ACK_FAILURE;
      status = A2DP_CTRL_ACK_FAILURE;
      break;

    case A2DP_CTRL_CMD_STOP:
@@ -472,7 +478,7 @@ uint8_t btif_a2dp_audio_process_request(uint8_t cmd) {
        break;
      }
      btif_av_stream_stop(RawAddress::kEmpty);
      return A2DP_CTRL_ACK_SUCCESS;
      status = A2DP_CTRL_ACK_SUCCESS;
      break;

    case A2DP_CTRL_CMD_SUSPEND:
@@ -502,5 +508,10 @@ uint8_t btif_a2dp_audio_process_request(uint8_t cmd) {
  }
  LOG_INFO(LOG_TAG, "a2dp-ctrl-cmd : %s DONE returning status %d",
           audio_a2dp_hw_dump_ctrl_event((tA2DP_CTRL_CMD)cmd), status);
  if (status == A2DP_CTRL_ACK_PENDING) {
    a2dp_cmd_pending = cmd;
  } else {
    a2dp_cmd_pending = A2DP_CTRL_CMD_NONE;
  }
  return status;
}