diff options
author | Eric Laurent <elaurent@google.com> | 2014-12-19 10:43:21 -0800 |
---|---|---|
committer | Eric Laurent <elaurent@google.com> | 2014-12-19 16:41:52 -0800 |
commit | 0f7b5f2b231caf87da9b20b74d086e5a9d6f4a9d (patch) | |
tree | f6f15345f054cdc13116a1443b80454e256b7c71 /services/audioflinger | |
parent | e48cf5b8f823c30af93577c1e380d752ac69b871 (diff) | |
download | frameworks_av-0f7b5f2b231caf87da9b20b74d086e5a9d6f4a9d.zip frameworks_av-0f7b5f2b231caf87da9b20b74d086e5a9d6f4a9d.tar.gz frameworks_av-0f7b5f2b231caf87da9b20b74d086e5a9d6f4a9d.tar.bz2 |
audioflinger: pause HW A/V sync output when AudioTrack underruns
Do not standby, starve or feed 0s to the audio HAL on direct
output using HW A/V sync mode.
Bug: 17883772.
Change-Id: I11e6c97ec24360d75f9b602814d40a54b60cb7a7
Diffstat (limited to 'services/audioflinger')
-rw-r--r-- | services/audioflinger/Threads.cpp | 15 | ||||
-rw-r--r-- | services/audioflinger/Threads.h | 3 |
2 files changed, 13 insertions, 5 deletions
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp index dacb12c..9fccda1 100644 --- a/services/audioflinger/Threads.cpp +++ b/services/audioflinger/Threads.cpp @@ -4083,6 +4083,10 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::DirectOutputThread::prep track->mRetryCount = kMaxTrackRetriesDirect; mActiveTrack = t; mixerStatus = MIXER_TRACKS_READY; + if (usesHwAvSync() && mHwPaused) { + doHwResume = true; + mHwPaused = false; + } } } else { // clear effect chain input buffer if the last active track started underruns @@ -4111,9 +4115,6 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::DirectOutputThread::prep track->mState = TrackBase::STOPPED; } if (track->isStopped()) { - if (track->mState == TrackBase::FLUSHED) { - flushHw_l(); - } track->reset(); } tracksToRemove->add(track); @@ -4130,6 +4131,10 @@ AudioFlinger::PlaybackThread::mixer_state AudioFlinger::DirectOutputThread::prep android_atomic_or(CBLK_DISABLED, &cblk->mFlags); } else if (last) { mixerStatus = MIXER_TRACKS_ENABLED; + if (usesHwAvSync() && !mHwPaused && !mStandby) { + doHwPause = true; + mHwPaused = true; + } } } } @@ -4192,7 +4197,7 @@ void AudioFlinger::DirectOutputThread::threadLoop_mix() void AudioFlinger::DirectOutputThread::threadLoop_sleepTime() { // do not write to HAL when paused - if (mHwPaused) { + if (mHwPaused || (usesHwAvSync() && mStandby)) { sleepTime = idleSleepTime; return; } @@ -4237,7 +4242,7 @@ bool AudioFlinger::DirectOutputThread::shouldStandby_l() trackPaused = mTracks[mTracks.size() - 1]->isPaused(); } - return !mStandby && !trackPaused; + return !mStandby && !(trackPaused || (usesHwAvSync() && mHwPaused)); } // getTrackName_l() must be called with ThreadBase::mLock held diff --git a/services/audioflinger/Threads.h b/services/audioflinger/Threads.h index f5d0e27..1088843 100644 --- a/services/audioflinger/Threads.h +++ b/services/audioflinger/Threads.h @@ -710,6 +710,9 @@ protected: audio_patch_handle_t *handle); virtual status_t releaseAudioPatch_l(const audio_patch_handle_t handle); + bool usesHwAvSync() const { return (mType == DIRECT) && (mOutput != NULL) && + (mOutput->flags & AUDIO_OUTPUT_FLAG_HW_AV_SYNC); } + private: friend class AudioFlinger; // for numerous |