audio flinger: fix AEC and NS suspend logic
Make sure we suspend/restore AEC and NS only when the suspend condition
actually changes to avoid mismatch in number of suspends/restores
causing the ref counting mechanism to leave the effects in suspend mode
while they should not.
Also clear the suspend state on an effect session before parking it in
the orphan chains list so that it is in default state whne attached to a
new record thread.
Bug: 63015903
Test: verify that switching BT SCO on/off with Duo enables or disables
AEC and NS accordingly
Change-Id: I4d0f0bf818deca3952da3c67bb7e83cb500429c7
diff --git a/services/audioflinger/Effects.h b/services/audioflinger/Effects.h
index e37529e..e29798b 100644
--- a/services/audioflinger/Effects.h
+++ b/services/audioflinger/Effects.h
@@ -331,7 +331,8 @@
void setStrategy(uint32_t strategy)
{ mStrategy = strategy; }
- // suspend effect of the given type
+ // suspend or restore effects of the specified type. The number of suspend requests is counted
+ // and restore occurs once all suspend requests are cancelled.
void setEffectSuspended_l(const effect_uuid_t *type,
bool suspend);
// suspend all eligible effects
@@ -372,7 +373,7 @@
public:
SuspendedEffectDesc() : mRefCount(0) {}
- int mRefCount;
+ int mRefCount; // > 0 when suspended
effect_uuid_t mType;
wp<EffectModule> mEffect;
};
@@ -388,6 +389,8 @@
// types or implementations from the suspend/restore mechanism.
bool isEffectEligibleForSuspend(const effect_descriptor_t& desc);
+ static bool isEffectEligibleForBtNrecSuspend(const effect_uuid_t *type);
+
void clearInputBuffer_l(const sp<ThreadBase>& thread);
void setThread(const sp<ThreadBase>& thread);
@@ -414,6 +417,6 @@
// mSuspendedEffects lists all effects currently suspended in the chain.
// Use effect type UUID timelow field as key. There is no real risk of identical
// timeLow fields among effect type UUIDs.
- // Updated by updateSuspendedSessions_l() only.
+ // Updated by setEffectSuspended_l() and setEffectSuspendedAll_l() only.
KeyedVector< int, sp<SuspendedEffectDesc> > mSuspendedEffects;
};