AudioTrack: reduce retrograde motion spew

Change-Id: I96aced52b136ceea924aa3d9ef56374dd4c49784
Signed-off-by: Phil Burk <philburk@google.com>
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h
index 51d40bb..0ccd19e 100644
--- a/include/media/AudioTrack.h
+++ b/include/media/AudioTrack.h
@@ -839,6 +839,7 @@
                                                     // only used for offloaded and direct tracks.
 
     bool                    mPreviousTimestampValid;// true if mPreviousTimestamp is valid
+    bool                    mRetrogradeMotionReported; // reduce log spam
     AudioTimestamp          mPreviousTimestamp;     // used to detect retrograde motion
 
     audio_output_flags_t    mFlags;
diff --git a/media/libmedia/AudioTrack.cpp b/media/libmedia/AudioTrack.cpp
index 76d9169..bb47d3e 100644
--- a/media/libmedia/AudioTrack.cpp
+++ b/media/libmedia/AudioTrack.cpp
@@ -2227,11 +2227,18 @@
                     - mPreviousTimestamp.mPosition);
             // position can bobble slightly as an artifact; this hides the bobble
             static const int32_t MINIMUM_POSITION_DELTA = 8;
-            ALOGW_IF(deltaPosition < 0,
-                    "retrograde timestamp position corrected, %d = %u - %u",
-                    deltaPosition,
-                    timestamp.mPosition,
-                    mPreviousTimestamp.mPosition);
+            if (deltaPosition < 0) {
+                // Only report once per position instead of spamming the log.
+                if (!mRetrogradeMotionReported) {
+                    ALOGW("retrograde timestamp position corrected, %d = %u - %u",
+                            deltaPosition,
+                            timestamp.mPosition,
+                            mPreviousTimestamp.mPosition);
+                    mRetrogradeMotionReported = true;
+                }
+            } else {
+                mRetrogradeMotionReported = false;
+            }
             if (deltaPosition < MINIMUM_POSITION_DELTA) {
                 timestamp = mPreviousTimestamp;  // Use last valid timestamp.
             }