Merge "Normal tracks use triple buffering if resampling" into nyc-dev am: 9b04a02250
am: d7290ab2c1

* commit 'd7290ab2c133e553cb3b0019cb2e970b0c73c211':
  Normal tracks use triple buffering if resampling

Change-Id: I48226c974af1e97cb9e297691ed33b922cd73d4f
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index 472f6c0..3ea5f15 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -1468,8 +1468,9 @@
             // notify every HAL buffer, regardless of the size of the track buffer
             maxNotificationFrames = afFrameCountHAL;
         } else {
-            // For normal tracks, use double-buffering
-            const int nBuffering = 2;
+            // For normal tracks, use at least double-buffering if no sample rate conversion,
+            // or at least triple-buffering if there is sample rate conversion
+            const int nBuffering = mOriginalSampleRate == mAfSampleRate ? 2 : 3;
             maxNotificationFrames = frameCount / nBuffering;
         }
         if (mNotificationFramesAct == 0 || mNotificationFramesAct > maxNotificationFrames) {