am 11e2e5de: Merge "AudioTrack: extend callback thread sleep time"

* commit '11e2e5dece7a92f50b73240dc0300343a7b495bf':
  AudioTrack: extend callback thread sleep time
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index f7895dd..3b94410 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -1127,6 +1127,11 @@
         frames = mRemainingFrames;
     }
 
+    int32_t waitCount = -1;
+    if (mUpdatePeriod || (!mMarkerReached && mMarkerPosition) || mLoopCount) {
+        waitCount = 1;
+    }
+
     do {
 
         audioBuffer.frameCount = frames;
@@ -1134,7 +1139,7 @@
         // Calling obtainBuffer() with a wait count of 1
         // limits wait time to WAIT_PERIOD_MS. This prevents from being
         // stuck here not being able to handle timed events (position, markers, loops).
-        status_t err = obtainBuffer(&audioBuffer, 1);
+        status_t err = obtainBuffer(&audioBuffer, waitCount);
         if (err < NO_ERROR) {
             if (err != TIMED_OUT) {
                 LOGE_IF(err != status_t(NO_MORE_BUFFERS), "Error obtaining an audio buffer, giving up.");