AudioFlinger: Do not send down 0's on direct PCM track underrun
Without HW pause, 0's were sent down in direct PCM track underrun.
This might be OK for linear PCM, but for proportional/encapsulated
PCM data this is not acceptable. We avoid adding any 0's.
Test: directed test (see b/186596553)
Bug: 34711969
Bug: 157682459
Bug: 161089206
Bug: 186596553
Change-Id: I398915d11c5a3c2e8775c68ca7717cd9f826ecf1
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index ef92492..e964a09 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -6115,16 +6115,13 @@
mSleepTimeUs = mIdleSleepTimeUs;
return;
}
- if (mSleepTimeUs == 0) {
- if (mMixerStatus == MIXER_TRACKS_ENABLED) {
- mSleepTimeUs = mActiveSleepTimeUs;
- } else {
- mSleepTimeUs = mIdleSleepTimeUs;
- }
- } else if (mBytesWritten != 0 && audio_has_proportional_frames(mFormat)) {
- memset(mSinkBuffer, 0, mFrameCount * mFrameSize);
- mSleepTimeUs = 0;
+ if (mMixerStatus == MIXER_TRACKS_ENABLED) {
+ mSleepTimeUs = mActiveSleepTimeUs;
+ } else {
+ mSleepTimeUs = mIdleSleepTimeUs;
}
+ // Note: In S or later, we do not write zeroes for
+ // linear or proportional PCM direct tracks in underrun.
}
void AudioFlinger::DirectOutputThread::threadLoop_exit()