diff options
author | Jean-Michel Trivi <jmtrivi@google.com> | 2014-09-18 14:07:18 -0700 |
---|---|---|
committer | The Android Automerger <android-build@google.com> | 2014-09-18 21:20:13 -0700 |
commit | a7326b42c42f5014e8dabf18d69a8376b2f3f67d (patch) | |
tree | 59e128037e1ba35eab1be1595d72621ce322476e | |
parent | 4704de0ce240cf6d2c93846d38463bbbd03ad7cf (diff) | |
download | frameworks_av-a7326b42c42f5014e8dabf18d69a8376b2f3f67d.zip frameworks_av-a7326b42c42f5014e8dabf18d69a8376b2f3f67d.tar.gz frameworks_av-a7326b42c42f5014e8dabf18d69a8376b2f3f67d.tar.bz2 |
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
-rw-r--r-- | include/media/AudioEffect.h | 1 | ||||
-rw-r--r-- | media/libmedia/AudioEffect.cpp | 13 |
2 files changed, 11 insertions, 3 deletions
diff --git a/include/media/AudioEffect.h b/include/media/AudioEffect.h index f98002d..4932d40 100644 --- a/include/media/AudioEffect.h +++ b/include/media/AudioEffect.h @@ -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; }; diff --git a/media/libmedia/AudioEffect.cpp b/media/libmedia/AudioEffect.cpp index 35f6557..0d5d7e4 100644 --- a/media/libmedia/AudioEffect.cpp +++ b/media/libmedia/AudioEffect.cpp @@ -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); |