audioflinger: avoid removing the same effect from the audio HAL twice
Add a flag to record whether the effect has been added to the audio
HAL.
Bug: 191754292
Test: mm libaudioflinger, Google Meet
Change-Id: Iabe73c6029e8daeb0e5f6d983321cc989013451f
diff --git a/services/audioflinger/Effects.cpp b/services/audioflinger/Effects.cpp
index d3492d9..b267d88 100644
--- a/services/audioflinger/Effects.cpp
+++ b/services/audioflinger/Effects.cpp
@@ -558,7 +558,8 @@
mStatus(NO_INIT),
mMaxDisableWaitCnt(1), // set by configure(), should be >= 1
mDisableWaitCnt(0), // set by process() and updateState()
- mOffloaded(false)
+ mOffloaded(false),
+ mAddedToHal(false)
#ifdef FLOAT_EFFECT_CHAIN
, mSupportsFloat(false)
#endif
@@ -1080,7 +1081,12 @@
{
if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_PRE_PROC ||
(mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_POST_PROC) {
+ if (mAddedToHal) {
+ return;
+ }
+
(void)getCallback()->addEffectToHal(mEffectInterface);
+ mAddedToHal = true;
}
}
@@ -1176,7 +1182,12 @@
{
if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_PRE_PROC ||
(mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_POST_PROC) {
+ if (!mAddedToHal) {
+ return NO_ERROR;
+ }
+
getCallback()->removeEffectFromHal(mEffectInterface);
+ mAddedToHal = false;
}
return NO_ERROR;
}