aaudio: prevent noise upon disconnect
Also clean up the state machine handling in the data callback.
Prevent error callback sometimes being called twice for the same error.
Bug: 63342351
Bug: 63087953
Test: add sleep(2) to write_sine_callback.cpp before the requestStop()
Change-Id: I27737bcb0371052741f50bda9f65c5994ccf6fd9
diff --git a/media/libaaudio/src/utility/AAudioUtilities.h b/media/libaaudio/src/utility/AAudioUtilities.h
index f56be32..3afa976 100644
--- a/media/libaaudio/src/utility/AAudioUtilities.h
+++ b/media/libaaudio/src/utility/AAudioUtilities.h
@@ -346,15 +346,18 @@
*/
class AtomicRequestor {
public:
+
+ __attribute__((no_sanitize("integer")))
void request() {
- // TODO handle overflows, very unlikely
mRequested++;
}
+ __attribute__((no_sanitize("integer")))
bool isRequested() {
- return mRequested.load() > mAcknowledged.load();
+ return (mRequested.load() - mAcknowledged.load()) > 0;
}
+ __attribute__((no_sanitize("integer")))
void acknowledge() {
mAcknowledged++;
}