summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/FastMixer.cpp
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2012-05-14 16:37:13 -0700
committerGlenn Kasten <gkasten@google.com>2012-05-17 16:29:07 -0700
commit99c99d00beb43b939dedc9ffb07adb89f6a85ba5 (patch)
treea93aeb409fa2399bf552ea901793514f0cf79f6b /services/audioflinger/FastMixer.cpp
parent552477608b137fb66af126655c6865207a82d888 (diff)
downloadframeworks_av-99c99d00beb43b939dedc9ffb07adb89f6a85ba5.zip
frameworks_av-99c99d00beb43b939dedc9ffb07adb89f6a85ba5.tar.gz
frameworks_av-99c99d00beb43b939dedc9ffb07adb89f6a85ba5.tar.bz2
systrace for audio
Trace fast track buffer fill status for underruns etc. Move the definition of macro to Android.mk. No overhead if disabled. Change-Id: If0e83e21b61b059ca38f543f8a6ffb58e08c79ee
Diffstat (limited to 'services/audioflinger/FastMixer.cpp')
-rw-r--r--services/audioflinger/FastMixer.cpp21
1 files changed, 18 insertions, 3 deletions
diff --git a/services/audioflinger/FastMixer.cpp b/services/audioflinger/FastMixer.cpp
index e73257e..df9ec8e 100644
--- a/services/audioflinger/FastMixer.cpp
+++ b/services/audioflinger/FastMixer.cpp
@@ -17,8 +17,6 @@
#define LOG_TAG "FastMixer"
//#define LOG_NDEBUG 0
-//#define ATRACE_TAG ATRACE_TAG_AUDIO
-
#include <sys/atomics.h>
#include <time.h>
#include <utils/Log.h>
@@ -359,10 +357,17 @@ bool FastMixer::threadLoop()
// up to 1 ms. If enough active tracks all blocked in sequence, this would result
// in the overall fast mix cycle being delayed. Should use a non-blocking FIFO.
size_t framesReady = fastTrack->mBufferProvider->framesReady();
+#if defined(ATRACE_TAG) && (ATRACE_TAG != ATRACE_TAG_NEVER)
+ // I wish we had formatted trace names
+ char traceName[16];
+ strcpy(traceName, "framesReady");
+ traceName[11] = i + (i < 10 ? '0' : 'A' - 10);
+ traceName[12] = '\0';
+ ATRACE_INT(traceName, framesReady);
+#endif
FastTrackDump *ftDump = &dumpState->mTracks[i];
FastTrackUnderruns underruns = ftDump->mUnderruns;
if (framesReady < frameCount) {
- ATRACE_INT("underrun", i);
if (framesReady == 0) {
underruns.mBitFields.mEmpty++;
underruns.mBitFields.mMostRecent = UNDERRUN_EMPTY;
@@ -396,9 +401,13 @@ bool FastMixer::threadLoop()
// FIXME write() is non-blocking and lock-free for a properly implemented NBAIO sink,
// but this code should be modified to handle both non-blocking and blocking sinks
dumpState->mWriteSequence++;
+#if defined(ATRACE_TAG) && (ATRACE_TAG != ATRACE_TAG_NEVER)
Tracer::traceBegin(ATRACE_TAG, "write");
+#endif
ssize_t framesWritten = outputSink->write(mixBuffer, frameCount);
+#if defined(ATRACE_TAG) && (ATRACE_TAG != ATRACE_TAG_NEVER)
Tracer::traceEnd(ATRACE_TAG);
+#endif
dumpState->mWriteSequence++;
if (framesWritten >= 0) {
ALOG_ASSERT(framesWritten <= frameCount);
@@ -448,7 +457,9 @@ bool FastMixer::threadLoop()
}
}
if (sec > 0 || nsec > underrunNs) {
+#if defined(ATRACE_TAG) && (ATRACE_TAG != ATRACE_TAG_NEVER)
ScopedTrace st(ATRACE_TAG, "underrun");
+#endif
// FIXME only log occasionally
ALOGV("underrun: time since last cycle %d.%03ld sec",
(int) sec, nsec / 1000000L);
@@ -518,6 +529,10 @@ bool FastMixer::threadLoop()
// this store #4 is not atomic with respect to stores #1, #2, #3 above, but
// the newest open and oldest closed halves are atomic with respect to each other
dumpState->mBounds = bounds;
+#if defined(ATRACE_TAG) && (ATRACE_TAG != ATRACE_TAG_NEVER)
+ ATRACE_INT("cycle_ms", monotonicNs / 1000000);
+ ATRACE_INT("load_us", loadNs / 1000);
+#endif
#endif
} else {
// first time through the loop