aaudio test: fix looping multiple times using -l
Wait for stream to pause before flushing.
Remove scary -110 result message.
Bug: 68271891
Test: adb shell write_sine_callback -pl -m2 -n2 -s2 -c2 -l100
Change-Id: Ide7e7642cbe0b9d43023106a526e8f1e205aab77
diff --git a/media/libaaudio/examples/utils/AAudioSimplePlayer.h b/media/libaaudio/examples/utils/AAudioSimplePlayer.h
index 2a59e46..1645986 100644
--- a/media/libaaudio/examples/utils/AAudioSimplePlayer.h
+++ b/media/libaaudio/examples/utils/AAudioSimplePlayer.h
@@ -223,6 +223,22 @@
return result;
}
+ aaudio_result_t waitUntilPaused() {
+ aaudio_result_t result = AAUDIO_OK;
+ aaudio_stream_state_t currentState = AAudioStream_getState(mStream);
+ aaudio_stream_state_t inputState = AAUDIO_STREAM_STATE_PAUSING;
+ while (result == AAUDIO_OK && currentState == AAUDIO_STREAM_STATE_PAUSING) {
+ result = AAudioStream_waitForStateChange(mStream, inputState,
+ ¤tState, NANOS_PER_SECOND);
+ inputState = currentState;
+ }
+ if (result != AAUDIO_OK) {
+ return result;
+ }
+ return (currentState == AAUDIO_STREAM_STATE_PAUSED)
+ ? AAUDIO_OK : AAUDIO_ERROR_INVALID_STATE;
+ }
+
// Flush the stream. AAudio will stop calling your callback function.
aaudio_result_t flush() {
aaudio_result_t result = AAudioStream_requestFlush(mStream);