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

Commit 5e8fe254 authored by Treehugger Robot's avatar Treehugger Robot Committed by Gerrit Code Review
Browse files

Merge "BluetoothAudioHAL: Wait for A2DP not playing if receiving A2dpSuspended=true"

parents b9adb81b c7dff690
Loading
Loading
Loading
Loading
+10 −2
Original line number Original line Diff line number Diff line
@@ -341,8 +341,12 @@ static int out_set_parameters(struct audio_stream* stream,
    if (params["A2dpSuspended"] == "true") {
    if (params["A2dpSuspended"] == "true") {
      LOG(INFO) << __func__ << ": state=" << out->bluetooth_output_.GetState()
      LOG(INFO) << __func__ << ": state=" << out->bluetooth_output_.GetState()
                << " stream param stopped";
                << " stream param stopped";
      if (out->bluetooth_output_.GetState() != BluetoothStreamState::DISABLED) {
      out->frames_rendered_ = 0;
      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();
        out->bluetooth_output_.Stop();
      }
      }
    } else {
    } else {
@@ -498,6 +502,10 @@ static ssize_t out_write(struct audio_stream_out* stream, const void* buffer,
    if (stream->resume(stream)) {
    if (stream->resume(stream)) {
      LOG(ERROR) << __func__ << ": state=" << out->bluetooth_output_.GetState()
      LOG(ERROR) << __func__ << ": state=" << out->bluetooth_output_.GetState()
                 << " failed to resume";
                 << " failed to resume";
      if (out->bluetooth_output_.GetState() == BluetoothStreamState::DISABLED) {
        // drop data for cases of A2dpSuspended=true / closing=true
        totalWritten = bytes;
      }
      usleep(kBluetoothDefaultOutputBufferMs * 1000);
      usleep(kBluetoothDefaultOutputBufferMs * 1000);
      return totalWritten;
      return totalWritten;
    }
    }