diff options
| author | Eric Laurent <elaurent@google.com> | 2015-06-09 17:18:58 +0000 | 
|---|---|---|
| committer | Android (Google) Code Review <android-gerrit@google.com> | 2015-06-09 17:18:59 +0000 | 
| commit | c75a989a38a157d48ca34bf127d5b4533e9356a7 (patch) | |
| tree | 6ba0deebf4deddd63f66874fa6346784192db009 | |
| parent | 9b132a7bdde8388f124e4db5ff54a88a93f8cdb6 (diff) | |
| parent | eecd7659823504c6c65a2b0f4267515a8e3f24cb (diff) | |
| download | frameworks_av-c75a989a38a157d48ca34bf127d5b4533e9356a7.zip frameworks_av-c75a989a38a157d48ca34bf127d5b4533e9356a7.tar.gz frameworks_av-c75a989a38a157d48ca34bf127d5b4533e9356a7.tar.bz2  | |
Merge "Use only strong references to AudioEffect" into mnc-dev
| -rw-r--r-- | include/media/AudioEffect.h | 28 | ||||
| -rw-r--r-- | media/libmedia/AudioEffect.cpp | 11 | 
2 files changed, 29 insertions, 10 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(); diff --git a/media/libmedia/AudioEffect.cpp b/media/libmedia/AudioEffect.cpp index bbeb854..ff82544 100644 --- a/media/libmedia/AudioEffect.cpp +++ b/media/libmedia/AudioEffect.cpp @@ -134,12 +134,14 @@ status_t AudioEffect::set(const effect_uuid_t *type,      if (iEffect == 0 || (mStatus != NO_ERROR && mStatus != ALREADY_EXISTS)) {          ALOGE("set(): AudioFlinger could not create effect, status: %d", mStatus); +        if (iEffect == 0) { +            mStatus = NO_INIT; +        }          return mStatus;      }      mEnabled = (volatile int32_t)enabled; -    mIEffect = iEffect;      cblk = iEffect->getCblk();      if (cblk == 0) {          mStatus = NO_INIT; @@ -147,6 +149,7 @@ 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); @@ -177,11 +180,11 @@ AudioEffect::~AudioEffect()              mIEffect->disconnect();              IInterface::asBinder(mIEffect)->unlinkToDeath(mIEffectClient);          } +        mIEffect.clear(); +        mCblkMemory.clear(); +        mIEffectClient.clear();          IPCThreadState::self()->flushCommands();      } -    mIEffect.clear(); -    mIEffectClient.clear(); -    mCblkMemory.clear();  }  | 
