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

Commit ce2a0b6d authored by Jeremy Wu's avatar Jeremy Wu
Browse files

Floss: clear a2dp_pending_cmd_ set in StopRequest

`StopRequest` sets `a2dp_pending_cmd_` unconditionally and expects it to be cleared in `btif_a2dp_source_on_stopped`.

However, that function only clears `a2dp_pending_cmd_` if the a2dp state
is not off, and this could be hard to guarantee and error-prone.

If `a2dp_pending_cmd_` does not get cleared in that case, it will stay
there and block further requests (e.g., StartRequest).

In this CL, we clear the variable the same way it is done in
`audio_hal_interface/a2dp_encoding.cc`, during `end_session`.

Also, we skip `stop_audio_request` in the interface when
there is no active stream on any A2DP device.

Bug: 240641968
Tag: #floss
Test: Build and verify
Change-Id: I1107620a79f0347b9f23dd8e11e2bd4f8f034454
parent d6a86101
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -242,6 +242,8 @@ void end_session() {

  // Reset remote delay. New value will be set when new session starts.
  remote_delay_report_ = 0;

  a2dp_pending_cmd_ = A2DP_CTRL_CMD_NONE;
}

void set_audio_low_latency_mode_allowed(bool allowed){
+5 −0
Original line number Diff line number Diff line
@@ -728,6 +728,11 @@ impl IBluetoothMedia for BluetoothMedia {
    }

    fn stop_audio_request(&mut self) {
        if !self.a2dp_audio_state.values().any(|state| *state == BtavAudioState::Started) {
            info!("No active stream on A2DP device, ignoring request to stop audio.");
            return;
        }

        match self.a2dp.as_mut() {
            Some(a2dp) => a2dp.stop_audio_request(),
            None => warn!("Uninitialized A2DP to stop audio request"),