AAudio: Add min number of bursts for SRC

When the SRC is used in AAudio, use at least 3 bursts.

Bug: 314003930
Test: OboeTester Test Output
Change-Id: I562474a75aa559c3a781a04d157c784572b70e66
diff --git a/media/libaaudio/src/client/AudioStreamInternal.cpp b/media/libaaudio/src/client/AudioStreamInternal.cpp
index ca0db0d..f431da8 100644
--- a/media/libaaudio/src/client/AudioStreamInternal.cpp
+++ b/media/libaaudio/src/client/AudioStreamInternal.cpp
@@ -64,6 +64,9 @@
 
 #define LOG_TIMESTAMPS            0
 
+// Minimum number of bursts to use when sample rate conversion is used.
+#define MIN_SAMPLE_RATE_CONVERSION_NUM_BURSTS    3
+
 AudioStreamInternal::AudioStreamInternal(AAudioServiceInterface  &serviceInterface, bool inService)
         : AudioStream()
         , mClockModel()
@@ -910,6 +913,12 @@
         numBursts = 1;
     }
 
+    // Set a minimum number of bursts if sample rate conversion is used.
+    if ((getSampleRate() != getDeviceSampleRate()) &&
+            (numBursts < MIN_SAMPLE_RATE_CONVERSION_NUM_BURSTS)) {
+        numBursts = MIN_SAMPLE_RATE_CONVERSION_NUM_BURSTS;
+    }
+
     if (mAudioEndpoint) {
         // Clip against the actual size from the endpoint.
         int32_t actualFramesDevice = 0;