Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 6c8ac4ba authored by David Li's avatar David Li
Browse files

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
parent 9782eef8
Loading
Loading
Loading
Loading
+12 −1
Original line number Original line Diff line number Diff line
@@ -558,7 +558,8 @@ AudioFlinger::EffectModule::EffectModule(const sp<AudioFlinger::EffectCallbackIn
      mStatus(NO_INIT),
      mStatus(NO_INIT),
      mMaxDisableWaitCnt(1), // set by configure(), should be >= 1
      mMaxDisableWaitCnt(1), // set by configure(), should be >= 1
      mDisableWaitCnt(0),    // set by process() and updateState()
      mDisableWaitCnt(0),    // set by process() and updateState()
      mOffloaded(false)
      mOffloaded(false),
      mAddedToHal(false)
#ifdef FLOAT_EFFECT_CHAIN
#ifdef FLOAT_EFFECT_CHAIN
      , mSupportsFloat(false)
      , mSupportsFloat(false)
#endif
#endif
@@ -1080,7 +1081,12 @@ void AudioFlinger::EffectModule::addEffectToHal_l()
{
{
    if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_PRE_PROC ||
    if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_PRE_PROC ||
         (mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_POST_PROC) {
         (mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_POST_PROC) {
        if (mAddedToHal) {
            return;
        }

        (void)getCallback()->addEffectToHal(mEffectInterface);
        (void)getCallback()->addEffectToHal(mEffectInterface);
        mAddedToHal = true;
    }
    }
}
}


@@ -1176,7 +1182,12 @@ status_t AudioFlinger::EffectModule::removeEffectFromHal_l()
{
{
    if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_PRE_PROC ||
    if ((mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_PRE_PROC ||
             (mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_POST_PROC) {
             (mDescriptor.flags & EFFECT_FLAG_TYPE_MASK) == EFFECT_FLAG_TYPE_POST_PROC) {
        if (!mAddedToHal) {
            return NO_ERROR;
        }

        getCallback()->removeEffectFromHal(mEffectInterface);
        getCallback()->removeEffectFromHal(mEffectInterface);
        mAddedToHal = false;
    }
    }
    return NO_ERROR;
    return NO_ERROR;
}
}
+1 −0
Original line number Original line Diff line number Diff line
@@ -286,6 +286,7 @@ private:
                                    // sending disable command.
                                    // sending disable command.
    uint32_t mDisableWaitCnt;       // current process() calls count during disable period.
    uint32_t mDisableWaitCnt;       // current process() calls count during disable period.
    bool     mOffloaded;            // effect is currently offloaded to the audio DSP
    bool     mOffloaded;            // effect is currently offloaded to the audio DSP
    bool     mAddedToHal;           // effect has been added to the audio HAL


#ifdef FLOAT_EFFECT_CHAIN
#ifdef FLOAT_EFFECT_CHAIN
    bool    mSupportsFloat;         // effect supports float processing
    bool    mSupportsFloat;         // effect supports float processing