diff options
author | Eric Laurent <elaurent@google.com> | 2015-06-04 16:20:16 -0700 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2015-06-08 18:47:51 -0700 |
commit | eecd7659823504c6c65a2b0f4267515a8e3f24cb (patch) | |
tree | 458dcc99c0a5a8ad6609ddec67bc903c388e4e8d /include | |
parent | d16a8ef26fd1f7a86061c396c5865564af2f1abb (diff) | |
download | frameworks_av-eecd7659823504c6c65a2b0f4267515a8e3f24cb.zip frameworks_av-eecd7659823504c6c65a2b0f4267515a8e3f24cb.tar.gz frameworks_av-eecd7659823504c6c65a2b0f4267515a8e3f24cb.tar.bz2 |
Use only strong references to AudioEffect
Do not refer to an AudioEffect instance by a raw pointer from the
child AudioEffectClient.
Also align destructor cleanup sequence on those of AudioTrack
and AudioRecord.
Bug: 21629892.
Change-Id: I970307aedbc38db2e41a2cc652fd6df9112f712c
Diffstat (limited to 'include')
-rw-r--r-- | include/media/AudioEffect.h | 28 |
1 files changed, 22 insertions, 6 deletions
diff --git a/include/media/AudioEffect.h b/include/media/AudioEffect.h index 61da4f2..5af6c10 100644 --- a/include/media/AudioEffect.h +++ b/include/media/AudioEffect.h @@ -429,7 +429,8 @@ protected: private: // Implements the IEffectClient interface - class EffectClient : public android::BnEffectClient, public android::IBinder::DeathRecipient + class EffectClient : + public android::BnEffectClient, public android::IBinder::DeathRecipient { public: @@ -437,24 +438,39 @@ private: // IEffectClient virtual void controlStatusChanged(bool controlGranted) { - mEffect->controlStatusChanged(controlGranted); + sp<AudioEffect> effect = mEffect.promote(); + if (effect != 0) { + effect->controlStatusChanged(controlGranted); + } } virtual void enableStatusChanged(bool enabled) { - mEffect->enableStatusChanged(enabled); + sp<AudioEffect> effect = mEffect.promote(); + if (effect != 0) { + effect->enableStatusChanged(enabled); + } } virtual void commandExecuted(uint32_t cmdCode, uint32_t cmdSize, void *pCmdData, uint32_t replySize, void *pReplyData) { - mEffect->commandExecuted(cmdCode, cmdSize, pCmdData, replySize, pReplyData); + sp<AudioEffect> effect = mEffect.promote(); + if (effect != 0) { + effect->commandExecuted( + cmdCode, cmdSize, pCmdData, replySize, pReplyData); + } } // IBinder::DeathRecipient - virtual void binderDied(const wp<IBinder>& who) {mEffect->binderDied();} + virtual void binderDied(const wp<IBinder>& who) { + sp<AudioEffect> effect = mEffect.promote(); + if (effect != 0) { + effect->binderDied(); + } + } private: - AudioEffect *mEffect; + wp<AudioEffect> mEffect; }; void binderDied(); |