From 182457597ea479674f7dceb871def902f6fe976c Mon Sep 17 00:00:00 2001 From: kuanyuhuang Date: Mon, 7 Aug 2023 05:05:52 +0000 Subject: [PATCH] BT: add LOW_LATENCY mode if low latency allowed LatencyMode is not updatable after audio session started. Currently, if low latency is allowed, audio session should have LOW_LATENCY latency mode. Create a workaround to add LOW_LATENCY when low_latency_allowed_ set to ture at ReportLowLatencyModeAllowedChanged. Bug: 291760415 Test: play low latency audio with supported headset and check LOW_LATENCY mode can be selected (cherry picked from https://android-review.googlesource.com/q/commit:25b4819e08280ea1bffa019a231e1d60edea7338) Merged-In: Ie0626179a56334125cd48a048d162f09882888eb Merged-In: I9d5510116225aa5857d1bd086956bc46d46a3eba Change-Id: Ia324f0a368e47ae8b8056c190d8d1f4a2e09ecec --- .../audio/utils/aidl_session/BluetoothAudioSession.cpp | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp index ee5527e62d..57a01c9d6f 100644 --- a/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp +++ b/bluetooth/audio/utils/aidl_session/BluetoothAudioSession.cpp @@ -440,6 +440,16 @@ void BluetoothAudioSession::ReportControlStatus(bool start_resp, void BluetoothAudioSession::ReportLowLatencyModeAllowedChanged(bool allowed) { std::lock_guard guard(mutex_); low_latency_allowed_ = allowed; + // TODO(b/294498919): Remove this after there is API to update latency mode + // after audio session started. If low_latency_allowed_ is true, the session + // can support LOW_LATENCY and FREE LatencyMode. + if (low_latency_allowed_) { + if (std::find(latency_modes_.begin(), latency_modes_.end(), + LatencyMode::LOW_LATENCY) == latency_modes_.end()) { + LOG(INFO) << __func__ << " - insert LOW_LATENCY LatencyMode"; + latency_modes_.push_back(LatencyMode::LOW_LATENCY); + } + } if (observers_.empty()) { LOG(WARNING) << __func__ << " - SessionType=" << toString(session_type_) << " has NO port state observer";