Fix issue 3388775.
Do not select A2DP output for media strategy when it is suspended because
BT SCO is active. Media audio will be routed to speakers or SCO HS
(depending on phone state and activity on stream VOICE_CALL) which is less
confusing than not hearing anything while music progress bar is moving.
Change-Id: Iff8cc1ea9bf9bde0b33035c4d91398db0934b836
diff --git a/services/audioflinger/AudioPolicyManagerBase.cpp b/services/audioflinger/AudioPolicyManagerBase.cpp
index bfc80db..74be4e0 100644
--- a/services/audioflinger/AudioPolicyManagerBase.cpp
+++ b/services/audioflinger/AudioPolicyManagerBase.cpp
@@ -122,12 +122,12 @@
// request routing change if necessary
uint32_t newDevice = getNewDevice(mHardwareOutput, false);
#ifdef WITH_A2DP
+ checkA2dpSuspend();
checkOutputForAllStrategies();
// A2DP outputs must be closed after checkOutputForAllStrategies() is executed
if (state == AudioSystem::DEVICE_STATE_UNAVAILABLE && AudioSystem::isA2dpDevice(device)) {
closeA2dpOutputs();
}
- checkA2dpSuspend();
#endif
updateDeviceForStrategy();
setOutputDevice(mHardwareOutput, newDevice);
@@ -269,8 +269,8 @@
// check for device and output changes triggered by new phone state
newDevice = getNewDevice(mHardwareOutput, false);
#ifdef WITH_A2DP
- checkOutputForAllStrategies();
checkA2dpSuspend();
+ checkOutputForAllStrategies();
#endif
updateDeviceForStrategy();
@@ -378,8 +378,8 @@
// check for device and output changes triggered by new phone state
uint32_t newDevice = getNewDevice(mHardwareOutput, false);
#ifdef WITH_A2DP
- checkOutputForAllStrategies();
checkA2dpSuspend();
+ checkOutputForAllStrategies();
#endif
updateDeviceForStrategy();
setOutputDevice(mHardwareOutput, newDevice);
@@ -1624,7 +1624,7 @@
if (device) break;
#ifdef WITH_A2DP
// when not in a phone call, phone strategy should route STREAM_VOICE_CALL to A2DP
- if (!isInCall()) {
+ if (!isInCall() && !mA2dpSuspended) {
device = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_BLUETOOTH_A2DP;
if (device) break;
device = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES;
@@ -1647,7 +1647,7 @@
#ifdef WITH_A2DP
// when not in a phone call, phone strategy should route STREAM_VOICE_CALL to
// A2DP speaker when forcing to speaker output
- if (!isInCall()) {
+ if (!isInCall() && !mA2dpSuspended) {
device = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER;
if (device) break;
}
@@ -1687,7 +1687,7 @@
device2 = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_WIRED_HEADSET;
}
#ifdef WITH_A2DP
- if ((mA2dpOutput != 0) &&
+ if ((mA2dpOutput != 0) && !mA2dpSuspended &&
(strategy != STRATEGY_SONIFICATION || a2dpUsedForSonification())) {
if (device2 == 0) {
device2 = mAvailableOutputDevices & AudioSystem::DEVICE_OUT_BLUETOOTH_A2DP;