AudioFlinger: Fix direct output resource from being occupied for too long
When flush immediately follows pause, mState might be overwritten and not
processed. In this case, direct output will retry due to data underrun.
In the duration of retry, the ActiveCount in AudioPolicy will be
positive and user can't create new track.
Add isPausePending to make sure pause will be handled by the
direct output thread.
Test: Manual (see bug)
Test: Clarity MediaPlayer Offloaded with seek.
Bug: 175092336
Change-Id: Ief742d2ce44917da24885373a5770e47876bc3a5
diff --git a/services/audioflinger/Tracks.cpp b/services/audioflinger/Tracks.cpp
index fb43a6e..4353b3d 100644
--- a/services/audioflinger/Tracks.cpp
+++ b/services/audioflinger/Tracks.cpp
@@ -1177,6 +1177,9 @@
mState = PAUSING;
ALOGV("%s(%d): ACTIVE/RESUMING => PAUSING on thread %d",
__func__, mId, (int)mThreadIoHandle);
+ if (isOffloadedOrDirect()) {
+ mPauseHwPending = true;
+ }
playbackThread->broadcast_l();
break;
@@ -1264,6 +1267,11 @@
mFlushHwPending = false;
}
+void AudioFlinger::PlaybackThread::Track::pauseAck()
+{
+ mPauseHwPending = false;
+}
+
void AudioFlinger::PlaybackThread::Track::reset()
{
// Do not reset twice to avoid discarding data written just after a flush and before