AudioFlinger: Fix incorrect underrun count on track pause
Also add track state name helper function for logging.
Test: Play video clip then pause and resume several times
Bug: 145613591
Change-Id: If4fc2565da9b3d4964fb9fdb6f5854ff6fbadfb8
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 4be21b1..e3cabcd 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -3616,7 +3616,13 @@
// Tally underrun frames as we are inserting 0s here.
for (const auto& track : activeTracks) {
- if (track->mFillingUpStatus == Track::FS_ACTIVE) {
+ if (track->mFillingUpStatus == Track::FS_ACTIVE
+ && !track->isStopped()
+ && !track->isPaused()
+ && !track->isTerminated()) {
+ ALOGV("%s: track(%d) %s underrun due to thread sleep of %zu frames",
+ __func__, track->id(), track->getTrackStateAsString(),
+ mNormalFrameCount);
track->mAudioTrackServerProxy->tallyUnderrunFrames(mNormalFrameCount);
}
}