diff options
author | Glenn Kasten <gkasten@google.com> | 2014-05-13 10:39:51 -0700 |
---|---|---|
committer | Glenn Kasten <gkasten@google.com> | 2014-06-24 14:23:51 -0700 |
commit | 4d23ca370dd0ce584f49a80ef9dfcdbb75ba2c8e (patch) | |
tree | 8bde5cebd55bd04d58c4200f6879984e863d2b77 /services/audioflinger | |
parent | c27f5259cf2c45ea6f0a021fc17578f32f6c2f7d (diff) | |
download | frameworks_av-4d23ca370dd0ce584f49a80ef9dfcdbb75ba2c8e.zip frameworks_av-4d23ca370dd0ce584f49a80ef9dfcdbb75ba2c8e.tar.gz frameworks_av-4d23ca370dd0ce584f49a80ef9dfcdbb75ba2c8e.tar.bz2 |
Use sp<> instead of raw pointer for FastMixer
This avoids worry about the thread lifetime during tear-down.
Bug: 15858655
Change-Id: I896d24317bd6f53a574645cdf4cd514eaa205dd5
Diffstat (limited to 'services/audioflinger')
-rwxr-xr-x | services/audioflinger/Threads.cpp | 18 | ||||
-rw-r--r-- | services/audioflinger/Threads.h | 4 |
2 files changed, 10 insertions, 12 deletions
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp index 8ce819c..7a2a773 100755 --- a/services/audioflinger/Threads.cpp +++ b/services/audioflinger/Threads.cpp @@ -2862,8 +2862,6 @@ AudioFlinger::MixerThread::MixerThread(const sp<AudioFlinger>& audioFlinger, Aud } #endif - } else { - mFastMixer = NULL; } switch (kUseFastMixer) { @@ -2882,7 +2880,7 @@ AudioFlinger::MixerThread::MixerThread(const sp<AudioFlinger>& audioFlinger, Aud AudioFlinger::MixerThread::~MixerThread() { - if (mFastMixer != NULL) { + if (mFastMixer != 0) { FastMixerStateQueue *sq = mFastMixer->sq(); FastMixerState *state = sq->begin(); if (state->mCommand == FastMixerState::COLD_IDLE) { @@ -2904,7 +2902,7 @@ AudioFlinger::MixerThread::~MixerThread() ALOG_ASSERT(fastTrack->mBufferProvider != NULL); delete fastTrack->mBufferProvider; sq->end(false /*didModify*/); - delete mFastMixer; + mFastMixer.clear(); #ifdef AUDIO_WATCHDOG if (mAudioWatchdog != 0) { mAudioWatchdog->requestExit(); @@ -2920,7 +2918,7 @@ AudioFlinger::MixerThread::~MixerThread() uint32_t AudioFlinger::MixerThread::correctLatency_l(uint32_t latency) const { - if (mFastMixer != NULL) { + if (mFastMixer != 0) { MonoPipe *pipe = (MonoPipe *)mPipeSink.get(); latency += (pipe->getAvgFrames() * 1000) / mSampleRate; } @@ -2937,7 +2935,7 @@ ssize_t AudioFlinger::MixerThread::threadLoop_write() { // FIXME we should only do one push per cycle; confirm this is true // Start the fast mixer if it's not already running - if (mFastMixer != NULL) { + if (mFastMixer != 0) { FastMixerStateQueue *sq = mFastMixer->sq(); FastMixerState *state = sq->begin(); if (state->mCommand != FastMixerState::MIX_WRITE && @@ -2971,7 +2969,7 @@ ssize_t AudioFlinger::MixerThread::threadLoop_write() void AudioFlinger::MixerThread::threadLoop_standby() { // Idle the fast mixer if it's currently running - if (mFastMixer != NULL) { + if (mFastMixer != 0) { FastMixerStateQueue *sq = mFastMixer->sq(); FastMixerState *state = sq->begin(); if (!(state->mCommand & FastMixerState::IDLE)) { @@ -3134,7 +3132,7 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::MixerThread::prepareTrac FastMixerState *state = NULL; bool didModify = false; FastMixerStateQueue::block_t block = FastMixerStateQueue::BLOCK_UNTIL_PUSHED; - if (mFastMixer != NULL) { + if (mFastMixer != 0) { sq = mFastMixer->sq(); state = sq->begin(); } @@ -3677,7 +3675,7 @@ bool AudioFlinger::MixerThread::checkForNewParameter_l(const String8& keyValuePa // if !&IDLE, holds the FastMixer state to restore after new parameters processed FastMixerState::Command previousCommand = FastMixerState::HOT_IDLE; - if (mFastMixer != NULL) { + if (mFastMixer != 0) { FastMixerStateQueue *sq = mFastMixer->sq(); FastMixerState *state = sq->begin(); if (!(state->mCommand & FastMixerState::IDLE)) { @@ -3782,7 +3780,7 @@ bool AudioFlinger::MixerThread::checkForNewParameter_l(const String8& keyValuePa } if (!(previousCommand & FastMixerState::IDLE)) { - ALOG_ASSERT(mFastMixer != NULL); + ALOG_ASSERT(mFastMixer != 0); FastMixerStateQueue *sq = mFastMixer->sq(); FastMixerState *state = sq->begin(); ALOG_ASSERT(state->mCommand == FastMixerState::HOT_IDLE); diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h index 07887fb..93d2635 100644 --- a/services/audioflinger/Threads.h +++ b/services/audioflinger/Threads.h @@ -852,7 +852,7 @@ protected: AudioMixer* mAudioMixer; // normal mixer private: // one-time initialization, no locks required - FastMixer* mFastMixer; // non-NULL if there is also a fast mixer + sp<FastMixer> mFastMixer; // non-0 if there is also a fast mixer sp<AudioWatchdog> mAudioWatchdog; // non-0 if there is an audio watchdog thread // contents are not guaranteed to be consistent, no locks required @@ -868,7 +868,7 @@ private: int32_t mFastMixerFutex; // for cold idle public: - virtual bool hasFastMixer() const { return mFastMixer != NULL; } + virtual bool hasFastMixer() const { return mFastMixer != 0; } virtual FastTrackUnderruns getFastTrackUnderruns(size_t fastIndex) const { ALOG_ASSERT(fastIndex < FastMixerState::kMaxFastTracks); return mFastMixerDumpState.mTracks[fastIndex].mUnderruns; |