Produce log warning when a glitch occurred.
A glitch is assumed to occur when the sum of the three
latest buffer periods cause CPU time to be unavailable
for the next buffer. For example, if a buffer period
is 4 ms, requires 3 ms of CPU time, and a running sum of
3 consecutive buffer periods is examined, this sum cannot
exceed 13 = 3*4 + (4-3), where 3*4 is the expected total
time and (4-3) is the CPU time left available by one 4 ms
period. Glitch examples:
4 + 4 + 6; 5 + 4 + 5; 2 + 2 + 10
See NBLog::Reader::alertIfGlitch.
Boolean NBLog::Reader::findGlitch should be set to true
for the notification to occur.
Note: this function needs to be developed to track glitch
occurrences over time and notify when a difference in
trend occurs.
Test: dumpsys media.log
logcat | grep NBLog
Change-Id: Ibf120afd990a71eb40863157a28c3a5a4a610c64
diff --git a/media/libnbaio/include/NBLog.h b/media/libnbaio/include/NBLog.h
index 19232ff..d1d9387 100644
--- a/media/libnbaio/include/NBLog.h
+++ b/media/libnbaio/include/NBLog.h
@@ -424,7 +424,6 @@
// iterator to end of readable segment of snapshot
EntryIterator end() { return mEnd; }
-
private:
friend class Reader;
uint8_t *mData;
@@ -440,6 +439,8 @@
virtual ~Reader();
+ void alertIfGlitch(const std::vector<int64_t> &samples);
+
// get snapshot of readers fifo buffer, effectively consuming the buffer
std::unique_ptr<Snapshot> getSnapshot();
// dump a particular snapshot of the reader
@@ -447,6 +448,9 @@
// dump the current content of the reader's buffer
void dump(int fd, size_t indent = 0);
bool isIMemory(const sp<IMemory>& iMemory) const;
+ // if findGlitch is true, log warning when buffer periods caused glitch
+ void setFindGlitch(bool s);
+ bool isFindGlitch() const;
private:
static const std::set<Event> startingTypes;
@@ -480,6 +484,8 @@
const std::set<Event> &types);
static const size_t kSquashTimestamp = 5; // squash this many or more adjacent timestamps
+
+ bool findGlitch; // alert if a local buffer period sequence caused an audio glitch
};
// Wrapper for a reader with a name. Contains a pointer to the reader and a pointer to the name