audioflinger: pause direct output when buffer timeout
Previously, direct output can be paused when underrun is observed
for the first time, this can interrupt the playback even there is
PCM data cached in the driver, and underrun may be recovered
within on the next loop cycle. Pausing the HAL is unnecessary at
this time.
Only do HAL pausing when track is going to be removed for buffer
timeout, allow the client to fill the buffer for the next loop
cycle.
Test: directed test (see b/186596553)
Bug: 34711969
Bug: 157682459
Bug: 161089206
Bug: 186596553
authored-by: Zhou Song <zhous@codeaurora.org>
Change-Id: I3707d883d0daa4ffd2baa9bd69aebf4bf9ddef4e
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 6da4543..50ef454 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -6033,15 +6033,17 @@
// indicate to client process that the track was disabled because of underrun;
// it will then automatically call start() when data is available
track->disable();
- } else if (last) {
+ // only do hw pause when track is going to be removed due to BUFFER TIMEOUT.
+ // unlike mixerthread, HAL can be paused for direct output
ALOGW("pause because of UNDERRUN, framesReady = %zu,"
"minFrames = %u, mFormat = %#x",
framesReady, minFrames, mFormat);
- mixerStatus = MIXER_TRACKS_ENABLED;
- if (mHwSupportsPause && !mHwPaused && !mStandby) {
+ if (last && mHwSupportsPause && !mHwPaused && !mStandby) {
doHwPause = true;
mHwPaused = true;
}
+ } else if (last) {
+ mixerStatus = MIXER_TRACKS_ENABLED;
}
}
}