audio: Fix AudioTrack stuck while interrupting waitStreamEndDone
When AudioTrack is waiting for waitStreamEndDone() and there is interrupt coming.
There is timing issue that AudioTrack will not enter STATE_STOPPED and be stuck at
requestExitAndWait().
Move interrupt after exit flag be set to prevent this problem.
Bug: 208191856
Test: atest CtsMediaTestCases
Change-Id: I2a42b99ae4d33ff95db2a736585475b4ee636d04
diff --git a/media/libaudioclient/AudioTrack.cpp b/media/libaudioclient/AudioTrack.cpp
index 5f802de..9f5ac19 100644
--- a/media/libaudioclient/AudioTrack.cpp
+++ b/media/libaudioclient/AudioTrack.cpp
@@ -352,8 +352,8 @@
// Otherwise the callback thread will never exit.
stop();
if (mAudioTrackThread != 0) { // not thread safe
- mProxy->interrupt();
mAudioTrackThread->requestExit(); // see comment in AudioTrack.h
+ mProxy->interrupt();
mAudioTrackThread->requestExitAndWait();
mAudioTrackThread.clear();
}