diff options
Diffstat (limited to 'services/audioflinger/FastThread.h')
-rw-r--r-- | services/audioflinger/FastThread.h | 60 |
1 files changed, 57 insertions, 3 deletions
diff --git a/services/audioflinger/FastThread.h b/services/audioflinger/FastThread.h index 6caf7bd..1330334 100644 --- a/services/audioflinger/FastThread.h +++ b/services/audioflinger/FastThread.h @@ -17,7 +17,12 @@ #ifndef ANDROID_AUDIO_FAST_THREAD_H #define ANDROID_AUDIO_FAST_THREAD_H +#include "Configuration.h" +#ifdef CPU_FREQUENCY_STATISTICS +#include <cpustats/ThreadCpuUsage.h> +#endif #include <utils/Thread.h> +#include "FastThreadState.h" namespace android { @@ -25,11 +30,60 @@ namespace android { class FastThread : public Thread { public: - FastThread() : Thread(false /*canCallJava*/) { } - virtual ~FastThread() { } + FastThread(); + virtual ~FastThread(); + +private: + // implement Thread::threadLoop() + virtual bool threadLoop(); protected: - virtual bool threadLoop() = 0; + // callouts to subclass in same lexical order as they were in original FastMixer.cpp + // FIXME need comments + virtual const FastThreadState *poll() = 0; + virtual void setLog(NBLog::Writer *logWriter __unused) { } + virtual void onIdle() = 0; + virtual void onExit() = 0; + virtual bool isSubClassCommand(FastThreadState::Command command) = 0; + virtual void onStateChange() = 0; + virtual void onWork() = 0; + + // FIXME these former local variables need comments and to be renamed to have an "m" prefix + const FastThreadState *previous; + const FastThreadState *current; + struct timespec oldTs; + bool oldTsValid; + long sleepNs; // -1: busy wait, 0: sched_yield, > 0: nanosleep + long periodNs; // expected period; the time required to render one mix buffer + long underrunNs; // underrun likely when write cycle is greater than this value + long overrunNs; // overrun likely when write cycle is less than this value + long forceNs; // if overrun detected, force the write cycle to take this much time + long warmupNs; // warmup complete when write cycle is greater than to this value + FastThreadDumpState *mDummyDumpState; + FastThreadDumpState *dumpState; + bool ignoreNextOverrun; // used to ignore initial overrun and first after an underrun +#ifdef FAST_MIXER_STATISTICS + struct timespec oldLoad; // previous value of clock_gettime(CLOCK_THREAD_CPUTIME_ID) + bool oldLoadValid; // whether oldLoad is valid + uint32_t bounds; + bool full; // whether we have collected at least mSamplingN samples +#ifdef CPU_FREQUENCY_STATISTICS + ThreadCpuUsage tcu; // for reading the current CPU clock frequency in kHz +#endif +#endif + unsigned coldGen; // last observed mColdGen + bool isWarm; // true means ready to mix, false means wait for warmup before mixing + struct timespec measuredWarmupTs; // how long did it take for warmup to complete + uint32_t warmupCycles; // counter of number of loop cycles required to warmup + NBLog::Writer dummyLogWriter; + NBLog::Writer *logWriter; + status_t timestampStatus; + + FastThreadState::Command command; +#if 0 + size_t frameCount; +#endif + bool attemptedWrite; }; // class FastThread |