From 9dfdb686aa8f2fcf67aaf480ffa0f110ad6b2e99 Mon Sep 17 00:00:00 2001 From: Cheney Ni Date: Fri, 24 Jul 2020 09:54:51 +0800 Subject: [PATCH] BTAudio: report session ended after cleaning up While Bluetooth stack ending a session, this CL does clean up first, and then reports the change. All observers are able to get the correct session state by invoking IsSessionReady() within the change callback. Bug: 162065063 Test: manually Change-Id: I920ea578d626d2e5844eb7c8a701636e20d7a219 --- .../audio/2.0/default/session/BluetoothAudioSession.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/bluetooth/audio/2.0/default/session/BluetoothAudioSession.cpp b/bluetooth/audio/2.0/default/session/BluetoothAudioSession.cpp index d60e7324f3..50119bf399 100644 --- a/bluetooth/audio/2.0/default/session/BluetoothAudioSession.cpp +++ b/bluetooth/audio/2.0/default/session/BluetoothAudioSession.cpp @@ -90,14 +90,16 @@ void BluetoothAudioSession::OnSessionStarted( // bluetooth_audio outputs void BluetoothAudioSession::OnSessionEnded() { std::lock_guard guard(mutex_); - if (IsSessionReady()) { - ReportSessionStatus(); - } + bool toggled = IsSessionReady(); + LOG(INFO) << __func__ << " - SessionType=" << toString(session_type_); audio_config_ = (session_type_ == SessionType::A2DP_HARDWARE_OFFLOAD_DATAPATH ? kInvalidOffloadAudioConfiguration : kInvalidSoftwareAudioConfiguration); stack_iface_ = nullptr; UpdateDataPath(nullptr); + if (toggled) { + ReportSessionStatus(); + } } // invoking the registered session_changed_cb_