Merge "Correct MediaAudioTrackTest testPlaybackHeadPositionAfterStop" am: faf2c42
am: 256c15a

* commit '256c15afd371cdf7d19c2c1f3cd2862cf2f7e4a4':
  Correct MediaAudioTrackTest testPlaybackHeadPositionAfterStop
diff --git a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/audio/MediaAudioTrackTest.java b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/audio/MediaAudioTrackTest.java
index e884aba..eac5c28 100644
--- a/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/audio/MediaAudioTrackTest.java
+++ b/media/tests/MediaFrameworkTest/src/com/android/mediaframeworktest/functional/audio/MediaAudioTrackTest.java
@@ -386,6 +386,7 @@
         final int TEST_FORMAT = AudioFormat.ENCODING_PCM_16BIT;
         final int TEST_MODE = AudioTrack.MODE_STREAM;
         final int TEST_STREAM_TYPE = AudioManager.STREAM_MUSIC;
+        final int TEST_LOOP_CNT = 10;
         
         //-------- initialization --------------
         int minBuffSize = AudioTrack.getMinBufferSize(TEST_SR, TEST_CONF, TEST_FORMAT);
@@ -399,9 +400,14 @@
         track.play();
         Thread.sleep(100);
         track.stop();
-        Thread.sleep(100); // TODO: what is a sensible value?
-        int pos = track.getPlaybackHeadPosition();
-        log(TEST_NAME, "position ="+ pos);
+        int count = 0;
+        int pos;
+        do {
+            Thread.sleep(200);
+            pos = track.getPlaybackHeadPosition();
+            count++;
+        } while((pos != 0) && (count < TEST_LOOP_CNT));
+        log(TEST_NAME, "position =" + pos + ", read count ="+count);
         assertTrue(TEST_NAME, pos == 0);
         //-------- tear down      --------------
         track.release();