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/client/AudioStreamInternalCapture.cpp b/media/libaaudio/src/client/AudioStreamInternalCapture.cpp
index 5d311fc..1bbe443 100644
--- a/media/libaaudio/src/client/AudioStreamInternalCapture.cpp
+++ b/media/libaaudio/src/client/AudioStreamInternalCapture.cpp
@@ -268,7 +268,7 @@
if (callbackResult == AAUDIO_CALLBACK_RESULT_STOP) {
ALOGD("%s(): callback returned AAUDIO_CALLBACK_RESULT_STOP", __func__);
- result = systemStopFromCallback();
+ result = systemStopInternal();
break;
}
}