AudioTrack: Add getUnderrunCount()
This allows an app to detect application-level output glitches.
Underrun counts survive track recreation.
Change-Id: I8eb14e92f6fc1007718a29b0666ab51ace30cdb8
Bug: 25641253
Signed-off-by: Phil Burk <philburk@google.com>
diff --git a/include/media/AudioTrack.h b/include/media/AudioTrack.h
index fe4611c..602e1f3 100644
--- a/include/media/AudioTrack.h
+++ b/include/media/AudioTrack.h
@@ -305,6 +305,11 @@
*/
uint32_t latency() const { return mLatency; }
+ /* Returns the number of application-level buffer underruns
+ * since the AudioTrack was created.
+ */
+ uint32_t getUnderrunCount() const;
+
/* getters, see constructors and set() */
audio_stream_type_t streamType() const;
@@ -784,6 +789,8 @@
// FIXME enum is faster than strcmp() for parameter 'from'
status_t restoreTrack_l(const char *from);
+ uint32_t getUnderrunCount_l() const;
+
bool isOffloaded() const;
bool isDirect() const;
bool isOffloadedOrDirect() const;
@@ -911,6 +918,8 @@
bool mRetrogradeMotionReported; // reduce log spam
AudioTimestamp mPreviousTimestamp; // used to detect retrograde motion
+ uint32_t mUnderrunCountOffset; // updated when restoring tracks
+
audio_output_flags_t mFlags;
// const after set(), except for bits AUDIO_OUTPUT_FLAG_FAST and AUDIO_OUTPUT_FLAG_OFFLOAD.
// mLock must be held to read or write those bits reliably.