diff options
-rw-r--r-- | services/audioflinger/Android.mk | 7 | ||||
-rw-r--r-- | services/audioflinger/FastMixer.cpp | 31 |
2 files changed, 17 insertions, 21 deletions
diff --git a/services/audioflinger/Android.mk b/services/audioflinger/Android.mk index dc65833..6d42143 100644 --- a/services/audioflinger/Android.mk +++ b/services/audioflinger/Android.mk @@ -78,6 +78,13 @@ LOCAL_CFLAGS += -UFAST_TRACKS_AT_NON_NATIVE_SAMPLE_RATE # LOCAL_SRC_FILES += AudioWatchdog.cpp # LOCAL_CFLAGS += -DAUDIO_WATCHDOG +# Define ANDROID_SMP appropriately. Used to get inline tracing fast-path. +ifeq ($(TARGET_CPU_SMP),true) + LOCAL_CFLAGS += -DANDROID_SMP=1 +else + LOCAL_CFLAGS += -DANDROID_SMP=0 +endif + include $(BUILD_SHARED_LIBRARY) # diff --git a/services/audioflinger/FastMixer.cpp b/services/audioflinger/FastMixer.cpp index 0366dfe..5e6af16 100644 --- a/services/audioflinger/FastMixer.cpp +++ b/services/audioflinger/FastMixer.cpp @@ -17,10 +17,7 @@ #define LOG_TAG "FastMixer" //#define LOG_NDEBUG 0 -/** Uncomment for systrace. - * ATRACE_TAG will default to ATRACE_TAG_NEVER in the header. - */ -//#define ATRACE_TAG ATRACE_TAG_AUDIO +#define ATRACE_TAG ATRACE_TAG_AUDIO #include <sys/atomics.h> #include <time.h> @@ -376,14 +373,14 @@ 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 + if (ATRACE_ENABLED()) { + // 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); + } FastTrackDump *ftDump = &dumpState->mTracks[i]; FastTrackUnderruns underruns = ftDump->mUnderruns; if (framesReady < frameCount) { @@ -429,13 +426,9 @@ 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) ATRACE_BEGIN("write"); -#endif ssize_t framesWritten = outputSink->write(mixBuffer, frameCount); -#if defined(ATRACE_TAG) && (ATRACE_TAG != ATRACE_TAG_NEVER) ATRACE_END(); -#endif dumpState->mWriteSequence++; if (framesWritten >= 0) { ALOG_ASSERT(framesWritten <= frameCount); @@ -490,9 +483,7 @@ bool FastMixer::threadLoop() sleepNs = -1; if (isWarm) { if (sec > 0 || nsec > underrunNs) { -#if defined(ATRACE_TAG) && (ATRACE_TAG != ATRACE_TAG_NEVER) - ScopedTrace st(ATRACE_TAG, "underrun"); -#endif + ATRACE_NAME("underrun"); // FIXME only log occasionally ALOGV("underrun: time since last cycle %d.%03ld sec", (int) sec, nsec / 1000000L); @@ -572,10 +563,8 @@ 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 { |