Fix AudioTrack presentationComplete regression
Bug: 27310929
Change-Id: Id52299660d90b07220a4fd9996da53fe755a41f1
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index a67693f..e684fc2 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -960,9 +960,17 @@
(long long)mPresentationCompleteFrames, audioHalFrames);
}
- if ((!isOffloaded() && !isDirect() && !isFastTrack()
- && framesWritten >= mPresentationCompleteFrames
- && mAudioTrackServerProxy->isDrained()) || isOffloaded()) {
+ bool complete;
+ if (isOffloaded()) {
+ complete = true;
+ } else if (isDirect() || isFastTrack()) { // these do not go through linear map
+ complete = framesWritten >= mPresentationCompleteFrames;
+ } else { // Normal tracks, OutputTracks, and PatchTracks
+ complete = framesWritten >= mPresentationCompleteFrames
+ && mAudioTrackServerProxy->isDrained();
+ }
+
+ if (complete) {
triggerEvents(AudioSystem::SYNC_EVENT_PRESENTATION_COMPLETE);
mAudioTrackServerProxy->setStreamEndDone();
return true;