summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/Threads.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'services/audioflinger/Threads.cpp')
-rw-r--r--services/audioflinger/Threads.cpp15
1 files changed, 15 insertions, 0 deletions
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 12e09ab..b1e9c07 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -2101,6 +2101,7 @@ ssize_t AudioFlinger::PlaybackThread::threadLoop_write()
// If an NBAIO sink is present, use it to write the normal mixer's submix
if (mNormalSink != 0) {
+
const size_t count = mBytesRemaining / mFrameSize;
ATRACE_BEGIN("write");
@@ -2126,6 +2127,7 @@ ssize_t AudioFlinger::PlaybackThread::threadLoop_write()
size_t totalFramesWritten = mNormalSink->framesWritten();
if (totalFramesWritten >= mLatchD.mTimestamp.mPosition) {
mLatchD.mUnpresentedFrames = totalFramesWritten - mLatchD.mTimestamp.mPosition;
+ // mLatchD.mFramesReleased is set immediately before D is clocked into Q
mLatchDValid = true;
}
}
@@ -2418,6 +2420,18 @@ bool AudioFlinger::PlaybackThread::threadLoop()
logString = NULL;
}
+ // Gather the framesReleased counters for all active tracks,
+ // and latch them atomically with the timestamp.
+ // FIXME We're using raw pointers as indices. A unique track ID would be a better index.
+ mLatchD.mFramesReleased.clear();
+ size_t size = mActiveTracks.size();
+ for (size_t i = 0; i < size; i++) {
+ sp<Track> t = mActiveTracks[i].promote();
+ if (t != 0) {
+ mLatchD.mFramesReleased.add(t.get(),
+ t->mAudioTrackServerProxy->framesReleased());
+ }
+ }
if (mLatchDValid) {
mLatchQ = mLatchD;
mLatchDValid = false;
@@ -3093,6 +3107,7 @@ void AudioFlinger::MixerThread::threadLoop_mix()
sleepTime = 0;
standbyTime = systemTime() + standbyDelay;
//TODO: delay standby when effects have a tail
+
}
void AudioFlinger::MixerThread::threadLoop_sleepTime()