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

Commit 74a7752b authored by Cheney Ni's avatar Cheney Ni
Browse files

A2DP: Reset the HAL pending command flag while clean up

In order to switch the audio HAL between software and offloading
encoders, there is a static flag shared between two HAL interfaces, and
is used to know whether the stack is still handling a previous task.
If audio HAL asked to start or suspend the playback while disabling
Bluetooth, the flag was assigned, but might not reset after A2DP clean
up. Since this is a static variable, it would be a worng value after
re-enabled, and should be reset while clean up or HAL interfaces'
initialization.

Bug: 147394596
Test: Turn off Bluetooth when A2DP playback
Change-Id: If14235f9cc302895049404a562ca0a27f416a3f2
parent 23604ea8
Loading
Loading
Loading
Loading
+11 −2
Original line number Diff line number Diff line
@@ -53,7 +53,10 @@ class A2dpTransport : public ::bluetooth::audio::IBluetoothTransportInstance {
  A2dpTransport(SessionType sessionType)
      : IBluetoothTransportInstance(sessionType, {}),
        total_bytes_read_(0),
        data_position_({}){};
        data_position_({}) {
    a2dp_pending_cmd_ = A2DP_CTRL_CMD_NONE;
    remote_delay_report_ = 0;
  }

  BluetoothAudioCtrlAck StartRequest() override {
    // Check if a previous request is not finished
@@ -390,8 +393,12 @@ void cleanup() {
  if (!is_hal_2_0_enabled()) return;
  end_session();

  auto a2dp_sink = active_hal_interface->GetTransportInstance();
  static_cast<A2dpTransport*>(a2dp_sink)->ResetPendingCmd();
  static_cast<A2dpTransport*>(a2dp_sink)->ResetPresentationPosition();
  active_hal_interface = nullptr;
  auto a2dp_sink = software_hal_interface->GetTransportInstance();

  a2dp_sink = software_hal_interface->GetTransportInstance();
  delete software_hal_interface;
  software_hal_interface = nullptr;
  delete a2dp_sink;
@@ -457,6 +464,8 @@ void end_session() {
    return;
  }
  active_hal_interface->EndSession();
  static_cast<A2dpTransport*>(active_hal_interface->GetTransportInstance())
      ->ResetPresentationPosition();
}

void ack_stream_started(const tA2DP_CTRL_ACK& ack) {