summaryrefslogtreecommitdiffstats
path: root/media
diff options
context:
space:
mode:
authorEric Laurent <elaurent@google.com>2013-05-03 15:39:52 +0000
committerAndroid (Google) Code Review <android-gerrit@google.com>2013-05-03 15:39:53 +0000
commita6560120f96685d7929d535319198485d1d5ccdf (patch)
tree0253af44cdc42fc828e84953531f36807ebc4f91 /media
parent98e099aca2089decdf3486ae216c89766cc252f2 (diff)
parentf8197a6a9d9363cb52bb8a2c15c0e5a52064355e (diff)
downloadframeworks_av-a6560120f96685d7929d535319198485d1d5ccdf.zip
frameworks_av-a6560120f96685d7929d535319198485d1d5ccdf.tar.gz
frameworks_av-a6560120f96685d7929d535319198485d1d5ccdf.tar.bz2
Merge "Remove timing jitter during startup of audio" into jb-mr2-dev
Diffstat (limited to 'media')
-rw-r--r--media/libmedia/AudioTrack.cpp21
1 files changed, 21 insertions, 0 deletions
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index 1bd839f..7eeb4f8 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -893,9 +893,11 @@ status_t AudioTrack::createTrack_l(
ALOGW("Requested frameCount %u but received frameCount %u", frameCount, temp);
}
frameCount = temp;
+ mAwaitBoost = false;
if (flags & AUDIO_OUTPUT_FLAG_FAST) {
if (trackFlags & IAudioFlinger::TRACK_FAST) {
ALOGV("AUDIO_OUTPUT_FLAG_FAST successful; frameCount %u", frameCount);
+ mAwaitBoost = true;
} else {
ALOGV("AUDIO_OUTPUT_FLAG_FAST denied by server; frameCount %u", frameCount);
// once denied, do not request again if IAudioTrack is re-created
@@ -1219,6 +1221,25 @@ bool AudioTrack::processAudioBuffer(const sp<AudioTrackThread>& thread)
size_t writtenSize;
mLock.lock();
+ if (mAwaitBoost) {
+ mAwaitBoost = false;
+ mLock.unlock();
+ static const int32_t kMaxTries = 5;
+ int32_t tryCounter = kMaxTries;
+ uint32_t pollUs = 10000;
+ do {
+ int policy = sched_getscheduler(0);
+ if (policy == SCHED_FIFO || policy == SCHED_RR) {
+ break;
+ }
+ usleep(pollUs);
+ pollUs <<= 1;
+ } while (tryCounter-- > 0);
+ if (tryCounter < 0) {
+ ALOGE("did not receive expected priority boost on time");
+ }
+ return true;
+ }
// acquire a strong reference on the IMemory and IAudioTrack so that they cannot be destroyed
// while we are accessing the cblk
sp<IAudioTrack> audioTrack = mAudioTrack;