Fix audio glitch when starting/stopping HFP call
When audio is playing and HFP call is started
there can be observed multiple create/release
AudioPatch requests. When HFP call is started
and patch is created for non HFP audio source
it can be heard for few ms until patch
is released again.
In this approach connection will be invalidated
and connectAudioSource will be called only when
client primaryMix exists and its different
from strategy primaryMix or when client
lost its primary mix.
Bug: 351880230
Test: connect and disconnect HFP call
when radio is playing.
Merged-In: I6fd89f7a9be6bc461df9db171df8f1afd75aa2f8
Change-Id: I6fd89f7a9be6bc461df9db171df8f1afd75aa2f8
(cherry picked from commit ffd364b0a20d6bd47e44499b34b628357d95f3b7)
diff --git a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
index 811ca12..b7201f2 100644
--- a/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
+++ b/services/audiopolicy/managerdefault/AudioPolicyManager.cpp
@@ -7127,7 +7127,8 @@
if (status != OK) {
continue;
}
- if (client->getPrimaryMix() != primaryMix || client->hasLostPrimaryMix()) {
+ if ((client->getPrimaryMix() && client->getPrimaryMix() != primaryMix)
+ || client->hasLostPrimaryMix()) {
if (desc->isStrategyActive(psId) && maxLatency < desc->latency()) {
maxLatency = desc->latency();
}