audioflinger: fix for playback paused during track transition
The test case here involves two applications both of
which play the same music clip. When the 2nd application
ends playback, the 1st application must resume playback
where it left off. But it is possible that the new
AudioTrack.start() command from the 1st application is processed
after the 2nd application has paused and terminated.
This will prevent a flush to clear any state before playback
of the 1st application can resume. Direct thread thus
stays in pause state indefintely.
Issue unconditional flush for direct thread when a new
track is added to a direct output.
Test: partner CL submit, check compilation
Bug: 123082418
Change-Id: I33d36db35358a1b3b89dd5b2b8cb4db1f9c6d4a0
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index dd1eabf..d7c1824 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -5462,6 +5462,11 @@
mFlushPending = true;
}
}
+ } else if (previousTrack == 0) {
+ // there could be an old track added back during track transition for direct
+ // output, so always issues flush to flush data of the previous track if it
+ // was already destroyed with HAL paused, then flush can resume the playback
+ mFlushPending = true;
}
PlaybackThread::onAddNewTrack_l();
}