audioflinger: Do not report underruns for stopped or paused tracks
PlaybackThread::Track is missing checks for the track state
when reporting underruns. These checks present on other instances
when tallyUnderrunFrames is being called.
This eliminates fake underrun reportings when playing
multichannel tracks via deep buffer.
Bug: 36181621
Test: play multichannel track and check underrun count at the end
Change-Id: Ieff338b33807e66df91234d85b782ee383fe95b9
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index 5480513..8fefb36 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -597,7 +597,9 @@
status_t status = mServerProxy->obtainBuffer(&buf);
buffer->frameCount = buf.mFrameCount;
buffer->raw = buf.mRaw;
- if (buf.mFrameCount == 0) {
+ if (buf.mFrameCount == 0 && !isStopping() && !isStopped() && !isPaused()) {
+ ALOGV("underrun, framesReady(%zu) < framesDesired(%zd), state: %d",
+ buf.mFrameCount, desiredFrames, mState);
mAudioTrackServerProxy->tallyUnderrunFrames(desiredFrames);
} else {
mAudioTrackServerProxy->tallyUnderrunFrames(0);