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

Commit a7326b42 authored by Jean-Michel Trivi's avatar Jean-Michel Trivi Committed by The Android Automerger
Browse files

AudioEffect acquires session

Currently, users of audio sessions, AudioTrack and AudioRecord,
 are acquiring and releasing audio sessions according to their
 life-cycle. AudioEffect instances were not counting as users
 of an audio session. This caused an effect used on a session
 to be purged by AudioFlinger::purgeStaleEffects_l() whenever
 the last user of that session went away.
This CL makes AudioEffect acquire and release a session when
 created and destroyed.

Bug 15432115

Change-Id: I922532150009988d43872f9b5928044a830ae0b3
parent 4704de0c
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -449,6 +449,7 @@ private:
    sp<EffectClient>        mIEffectClient;     // IEffectClient implementation
    sp<IMemory>             mCblkMemory;        // shared memory for deferred parameter setting
    effect_param_cblk_t*    mCblk;              // control block for deferred parameter setting
    pid_t                   mClientPid;
};


+10 −3
Original line number Diff line number Diff line
@@ -145,15 +145,19 @@ status_t AudioEffect::set(const effect_uuid_t *type,
        return mStatus;
    }

    mIEffect = iEffect;
    mCblkMemory = cblk;
    mCblk = static_cast<effect_param_cblk_t*>(cblk->pointer());
    int bufOffset = ((sizeof(effect_param_cblk_t) - 1) / sizeof(int) + 1) * sizeof(int);
    mCblk->buffer = (uint8_t *)mCblk + bufOffset;

    iEffect->asBinder()->linkToDeath(mIEffectClient);
    ALOGV("set() %p OK effect: %s id: %d status %d enabled %d", this, mDescriptor.name, mId,
            mStatus, mEnabled);
    mClientPid = IPCThreadState::self()->getCallingPid();
    ALOGV("set() %p OK effect: %s id: %d status %d enabled %d pid %d", this, mDescriptor.name, mId,
            mStatus, mEnabled, mClientPid);

    if (mSessionId > AUDIO_SESSION_OUTPUT_MIX) {
        AudioSystem::acquireAudioSessionId(mSessionId, mClientPid);
    }

    return mStatus;
}
@@ -164,6 +168,9 @@ AudioEffect::~AudioEffect()
    ALOGV("Destructor %p", this);

    if (mStatus == NO_ERROR || mStatus == ALREADY_EXISTS) {
        if (mSessionId > AUDIO_SESSION_OUTPUT_MIX) {
            AudioSystem::releaseAudioSessionId(mSessionId, mClientPid);
        }
        if (mIEffect != NULL) {
            mIEffect->disconnect();
            mIEffect->asBinder()->unlinkToDeath(mIEffectClient);