diff options
author | Pavlin Radoslavov <pavlin@google.com> | 2018-07-10 17:24:01 -0700 |
---|---|---|
committer | Pavlin Radoslavov <pavlin@google.com> | 2018-07-10 17:52:07 -0700 |
commit | f590f6f9cd9b646a906bd967af24d6f279b533ae (patch) | |
tree | 8b07c5d4f68da7ffab59b308726cf6c2fd129e20 /src | |
parent | 4c00652497c48d4ac573307764824d8b262a82b8 (diff) | |
download | android_packages_apps_Bluetooth-f590f6f9cd9b646a906bd967af24d6f279b533ae.tar.gz android_packages_apps_Bluetooth-f590f6f9cd9b646a906bd967af24d6f279b533ae.tar.bz2 android_packages_apps_Bluetooth-f590f6f9cd9b646a906bd967af24d6f279b533ae.zip |
Explicitly mute the audio output while switching the A2DP Active Device
The mute/unmute of the audio output is needed during the A2DP
ActiveDevice switch to avoid audio glitches.
Bug: 78152025
Bug: 110441865
Test: Manual - stream with Pandora/Spotify and switch A2DP Active Device
Change-Id: I5a233460a07e0d4fffcb4e6cb208d846517f0c1e
(cherry picked from commit 075005f0ef8adf5397b9ed6210e0160f1a0314a5)
Diffstat (limited to 'src')
-rw-r--r-- | src/com/android/bluetooth/a2dp/A2dpService.java | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/com/android/bluetooth/a2dp/A2dpService.java b/src/com/android/bluetooth/a2dp/A2dpService.java index 10a2f8b5d..64a9cad6c 100644 --- a/src/com/android/bluetooth/a2dp/A2dpService.java +++ b/src/com/android/bluetooth/a2dp/A2dpService.java @@ -517,7 +517,14 @@ public class A2dpService extends ProfileService { } // Make sure the Audio Manager knows the previous Active device is disconnected, // and the new Active device is connected. + // Also, mute and unmute the output during the switch to avoid audio glitches. + boolean wasMuted = false; if (previousActiveDevice != null) { + if (!mAudioManager.isStreamMute(AudioManager.STREAM_MUSIC)) { + mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, + AudioManager.ADJUST_MUTE, 0); + wasMuted = true; + } mAudioManager.setBluetoothA2dpDeviceConnectionStateSuppressNoisyIntent( previousActiveDevice, BluetoothProfile.STATE_DISCONNECTED, BluetoothProfile.A2DP, true, -1); @@ -539,6 +546,10 @@ public class A2dpService extends ProfileService { // change, so the Audio Service can reset accordingly the audio // feeding parameters in the Audio HAL to the Bluetooth stack. mAudioManager.handleBluetoothA2dpDeviceConfigChange(mActiveDevice); + if (wasMuted) { + mAudioManager.adjustStreamVolume(AudioManager.STREAM_MUSIC, + AudioManager.ADJUST_UNMUTE, 0); + } } } return true; |