summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2010-09-30 16:12:31 -0700
committerEric Laurent <elaurent@google.com>2010-09-30 17:21:23 -0700
commit44d9848d6656777a18019223e0d35f2fcc67719a (patch)
treefe71003d3400dcbdfe078f8d8fad1b1fde960b2c /media
parent922855214d0e8ae4159794d7f751f780b3243552 (diff)
downloadframeworks_av-44d9848d6656777a18019223e0d35f2fcc67719a.zip
frameworks_av-44d9848d6656777a18019223e0d35f2fcc67719a.tar.gz
frameworks_av-44d9848d6656777a18019223e0d35f2fcc67719a.tar.bz2
Issue 3032913: improve AudioTrack recovery time
This issue showed that when an AudioTrack underruns during a too long period of time and is therefore disabled by audioflinger mixer, it takes an additional delay of up to 3 seconds to recover. This fix adds a simple mechanism to recover immediately when the client application is ready to write data again in the AudioTrack buffer Also throttle warnings on record overflows Change-Id: I8b2c71578dd134b9e60a15ee4d91b70f3799cb3d
Diffstat (limited to 'media')
-rw-r--r--media/libmedia/AudioTrack.cpp8
1 files changed, 8 insertions, 0 deletions
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index 890786e..587c8ff 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -316,6 +316,7 @@ void AudioTrack::start()
mNewPosition = mCblk->server + mUpdatePeriod;
mCblk->bufferTimeoutMs = MAX_STARTUP_TIMEOUT_MS;
mCblk->waitTimeMs = 0;
+ mCblk->flags &= ~CBLK_DISABLED_ON;
if (t != 0) {
t->run("AudioTrackThread", THREAD_PRIORITY_AUDIO_CLIENT);
} else {
@@ -842,6 +843,13 @@ create_new_track:
cblk->lock.unlock();
}
+ // restart track if it was disabled by audioflinger due to previous underrun
+ if (cblk->flags & CBLK_DISABLED_MSK) {
+ cblk->flags &= ~CBLK_DISABLED_ON;
+ LOGW("obtainBuffer() track %p disabled, restarting", this);
+ mAudioTrack->start();
+ }
+
cblk->waitTimeMs = 0;
if (framesReq > framesAvail) {