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

Commit 2145924a authored by Henri Chataing's avatar Henri Chataing
Browse files

audio_hal_interface: Refine implementation of A2DP StopRequest

Bug: 365022887
Test: m com.android.btservices
Test: Manual streaming test
Flag: EXEMPT, minor bug fix
Change-Id: Ia7138bbb1ecb9e3f2e0e3103a75823e46240d891
parent a0f0f303
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -55,6 +55,7 @@ public:
    return BluetoothAudioStatus::FAILURE;
  }
  virtual BluetoothAudioStatus SuspendStream() const { return BluetoothAudioStatus::FAILURE; }
  virtual BluetoothAudioStatus StopStream() const { return SuspendStream(); }
  virtual BluetoothAudioStatus SetLatencyMode(bool /*low_latency*/) const {
    return BluetoothAudioStatus::FAILURE;
  }
+1 −1
Original line number Diff line number Diff line
@@ -185,7 +185,7 @@ BluetoothAudioStatus A2dpTransport::SuspendRequest() {
void A2dpTransport::StopRequest() {
  log::info("");

  auto status = bluetooth_audio_port_->SuspendStream();
  auto status = bluetooth_audio_port_->StopStream();
  a2dp_pending_cmd_ =
          status == BluetoothAudioStatus::PENDING ? A2DP_CTRL_CMD_STOP : A2DP_CTRL_CMD_NONE;
}
+16 −0
Original line number Diff line number Diff line
@@ -364,6 +364,7 @@ class A2dpAudioPort : public bluetooth::audio::a2dp::BluetoothAudioPort {

    // Check if the stream has already been started.
    if (btif_av_stream_started_ready(A2dpType::kSource)) {
      log::verbose("stream is already started");
      return BluetoothAudioStatus::SUCCESS;
    }

@@ -386,6 +387,7 @@ class A2dpAudioPort : public bluetooth::audio::a2dp::BluetoothAudioPort {
    // Check if the stream is already suspended.
    if (!btif_av_stream_started_ready(A2dpType::kSource)) {
      btif_av_clear_remote_suspend_flag(A2dpType::kSource);
      log::verbose("stream is already suspended");
      return BluetoothAudioStatus::SUCCESS;
    }

@@ -395,6 +397,20 @@ class A2dpAudioPort : public bluetooth::audio::a2dp::BluetoothAudioPort {
    return BluetoothAudioStatus::PENDING;
  }

  BluetoothAudioStatus StopStream() const override {
    // Check if the stream is already suspended.
    if (!btif_av_stream_started_ready(A2dpType::kSource)) {
      btif_av_clear_remote_suspend_flag(A2dpType::kSource);
      log::verbose("stream is already stopped");
      return BluetoothAudioStatus::SUCCESS;
    }

    // Post stop event. The stop request is pending, but completion is not
    // notified to the HAL.
    btif_av_stream_stop(RawAddress::kEmpty);
    return BluetoothAudioStatus::PENDING;
  }

  BluetoothAudioStatus SetLatencyMode(bool low_latency) const override {
    btif_av_set_low_latency(low_latency);
    return BluetoothAudioStatus::SUCCESS;