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

Commit 9f57aa81 authored by Eric Laurent's avatar Eric Laurent
Browse files

audioflinger: fix input effect transfer

Allow to re attach an input effect to a new HAL
stream if it was not detached from previous stream

Bug: 223702982
Test: repro steps in bug
Change-Id: I052ff9484e68bccbbc6c4ff97198e96504f47066
parent 008b05ec
Loading
Loading
Loading
Loading
+5 −7
Original line number Original line Diff line number Diff line
@@ -570,7 +570,6 @@ AudioFlinger::EffectModule::EffectModule(const sp<AudioFlinger::EffectCallbackIn
      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),
      mIsOutput(false)
      mIsOutput(false)
#ifdef FLOAT_EFFECT_CHAIN
#ifdef FLOAT_EFFECT_CHAIN
      , mSupportsFloat(false)
      , mSupportsFloat(false)
@@ -1104,12 +1103,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) {
        if (mCurrentHalStream == getCallback()->io()) {
            return;
            return;
        }
        }


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


@@ -1205,12 +1204,11 @@ 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) {
        if (mCurrentHalStream != getCallback()->io()) {
            return NO_ERROR;
            return (mCurrentHalStream == AUDIO_IO_HANDLE_NONE) ? NO_ERROR : INVALID_OPERATION;
        }
        }

        getCallback()->removeEffectFromHal(mEffectInterface);
        getCallback()->removeEffectFromHal(mEffectInterface);
        mAddedToHal = false;
        mCurrentHalStream = AUDIO_IO_HANDLE_NONE;
    }
    }
    return NO_ERROR;
    return NO_ERROR;
}
}
+2 −1
Original line number Original line Diff line number Diff line
@@ -319,7 +319,8 @@ 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
    // effect has been added to this HAL input stream
    audio_io_handle_t mCurrentHalStream = AUDIO_IO_HANDLE_NONE;
    bool     mIsOutput;             // direction of the AF thread
    bool     mIsOutput;             // direction of the AF thread


#ifdef FLOAT_EFFECT_CHAIN
#ifdef FLOAT_EFFECT_CHAIN