aaudio: check for callback thread outside the lock
Calling AAudioStream_requestStop() from a callback is illegal.
But it should just return and error and not hang.
The hang can occur if AAudioStream_close() is called at the same time
from another thread.
Bug: 184370309
Test: adb shell test_disconnect_race
Change-Id: I5e0752611d4d3d3dd994a10e82a339fa39e65d42
diff --git a/media/libaaudio/src/legacy/AudioStreamLegacy.cpp b/media/libaaudio/src/legacy/AudioStreamLegacy.cpp
index fdaa2ab..60eb73a 100644
--- a/media/libaaudio/src/legacy/AudioStreamLegacy.cpp
+++ b/media/libaaudio/src/legacy/AudioStreamLegacy.cpp
@@ -124,7 +124,7 @@
__func__, callbackResult);
}
audioBuffer->size = 0;
- systemStopFromCallback();
+ systemStopInternal();
// Disable the callback just in case the system keeps trying to call us.
mCallbackEnabled.store(false);
}