diff options
author | Eric Laurent <elaurent@google.com> | 2010-09-30 19:47:21 -0700 |
---|---|---|
committer | Android Git Automerger <android-git-automerger@android.com> | 2010-09-30 19:47:21 -0700 |
commit | 785c416ecf627a550c15f33800fe3091482b181a (patch) | |
tree | 6224c4606fb35430cd96bf433b173ca1ae4a9c1b /services/audioflinger | |
parent | 13cc0a06fce4ec54574c9bf2084752961a144c24 (diff) | |
parent | de12c3cf56e3f27b2efc60eeae8b5e422747f2b9 (diff) | |
download | frameworks_base-785c416ecf627a550c15f33800fe3091482b181a.zip frameworks_base-785c416ecf627a550c15f33800fe3091482b181a.tar.gz frameworks_base-785c416ecf627a550c15f33800fe3091482b181a.tar.bz2 |
am de12c3cf: am 220ab887: Merge "Issue 3032913: improve AudioTrack recovery time" into gingerbread
Merge commit 'de12c3cf56e3f27b2efc60eeae8b5e422747f2b9'
* commit 'de12c3cf56e3f27b2efc60eeae8b5e422747f2b9':
Issue 3032913: improve AudioTrack recovery time
Diffstat (limited to 'services/audioflinger')
-rw-r--r-- | services/audioflinger/AudioFlinger.cpp | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/services/audioflinger/AudioFlinger.cpp b/services/audioflinger/AudioFlinger.cpp index 97b8086..8527059 100644 --- a/services/audioflinger/AudioFlinger.cpp +++ b/services/audioflinger/AudioFlinger.cpp @@ -1856,6 +1856,8 @@ uint32_t AudioFlinger::MixerThread::prepareTracks_l(const SortedVector< wp<Track if (--(track->mRetryCount) <= 0) { LOGV("BUFFER TIMEOUT: remove(%d) from active list on thread %p", track->name(), this); tracksToRemove->add(track); + // indicate to client process that the track was disabled because of underrun + cblk->flags |= CBLK_DISABLED_ON; } else if (mixerStatus != MIXER_TRACKS_READY) { mixerStatus = MIXER_TRACKS_ENABLED; } @@ -2790,7 +2792,7 @@ AudioFlinger::ThreadBase::TrackBase::TrackBase( mBuffer = (char*)mCblk + sizeof(audio_track_cblk_t); memset(mBuffer, 0, frameCount*channelCount*sizeof(int16_t)); // Force underrun condition to avoid false underrun callback until first data is - // written to buffer + // written to buffer (other flags are cleared) mCblk->flags = CBLK_UNDERRUN_ON; } else { mBuffer = sharedBuffer->pointer(); @@ -2813,7 +2815,7 @@ AudioFlinger::ThreadBase::TrackBase::TrackBase( mBuffer = (char*)mCblk + sizeof(audio_track_cblk_t); memset(mBuffer, 0, frameCount*channelCount*sizeof(int16_t)); // Force underrun condition to avoid false underrun callback until first data is - // written to buffer + // written to buffer (other flags are cleared) mCblk->flags = CBLK_UNDERRUN_ON; mBufferEnd = (uint8_t *)mBuffer + bufferSize; } @@ -3794,6 +3796,8 @@ bool AudioFlinger::RecordThread::threadLoop() AudioBufferProvider::Buffer buffer; sp<RecordTrack> activeTrack; + nsecs_t lastWarning = 0; + // start recording while (!exitPending()) { @@ -3935,8 +3939,13 @@ bool AudioFlinger::RecordThread::threadLoop() } // client isn't retrieving buffers fast enough else { - if (!mActiveTrack->setOverflow()) - LOGW("RecordThread: buffer overflow"); + if (!mActiveTrack->setOverflow()) { + nsecs_t now = systemTime(); + if ((now - lastWarning) > kWarningThrottle) { + LOGW("RecordThread: buffer overflow"); + lastWarning = now; + } + } // Release the processor for a while before asking for a new buffer. // This will give the application more chance to read from the buffer and // clear the overflow. |