diff options
author | Glenn Kasten <gkasten@google.com> | 2015-03-02 15:51:38 -0800 |
---|---|---|
committer | Glenn Kasten <gkasten@google.com> | 2015-03-03 08:52:56 -0800 |
commit | d702a568cb62e5aebe048147350bb3c76f9386ba (patch) | |
tree | 507e18b27556b74262a527a7378515fbdcf9b573 /services/audioflinger | |
parent | fbdb2aceab7317aa44bc8f301a93eb49e17b2bce (diff) | |
download | frameworks_av-d702a568cb62e5aebe048147350bb3c76f9386ba.zip frameworks_av-d702a568cb62e5aebe048147350bb3c76f9386ba.tar.gz frameworks_av-d702a568cb62e5aebe048147350bb3c76f9386ba.tar.bz2 |
Pull out commandToString() from FastMixerDumpState.cpp
to FastThreadState.cpp, FastMixerState.cpp, and FastCaptureState.cpp
Change-Id: I872efb211e8a0335c42906367859d3674340e374
Diffstat (limited to 'services/audioflinger')
-rw-r--r-- | services/audioflinger/FastCaptureState.cpp | 15 | ||||
-rw-r--r-- | services/audioflinger/FastCaptureState.h | 2 | ||||
-rw-r--r-- | services/audioflinger/FastMixerDumpState.cpp | 30 | ||||
-rw-r--r-- | services/audioflinger/FastMixerState.cpp | 15 | ||||
-rw-r--r-- | services/audioflinger/FastMixerState.h | 3 | ||||
-rw-r--r-- | services/audioflinger/FastThreadState.cpp | 12 | ||||
-rw-r--r-- | services/audioflinger/FastThreadState.h | 2 |
7 files changed, 50 insertions, 29 deletions
diff --git a/services/audioflinger/FastCaptureState.cpp b/services/audioflinger/FastCaptureState.cpp index 1d029b7..c4d5e45 100644 --- a/services/audioflinger/FastCaptureState.cpp +++ b/services/audioflinger/FastCaptureState.cpp @@ -27,4 +27,19 @@ FastCaptureState::~FastCaptureState() { } +// static +const char *FastCaptureState::commandToString(Command command) +{ + const char *str = FastThreadState::commandToString(command); + if (str != NULL) { + return str; + } + switch (command) { + case FastCaptureState::READ: return "READ"; + case FastCaptureState::WRITE: return "WRITE"; + case FastCaptureState::READ_WRITE: return "READ_WRITE"; + } + LOG_ALWAYS_FATAL("%s", __func__); +} + } // android diff --git a/services/audioflinger/FastCaptureState.h b/services/audioflinger/FastCaptureState.h index 29c865a..17302d3 100644 --- a/services/audioflinger/FastCaptureState.h +++ b/services/audioflinger/FastCaptureState.h @@ -44,6 +44,8 @@ struct FastCaptureState : FastThreadState { WRITE = 0x10, // write to pipe sink READ_WRITE = 0x18; // read from input source and write to pipe sink + // never returns NULL; asserts if command is invalid + static const char *commandToString(Command command); }; // struct FastCaptureState } // namespace android diff --git a/services/audioflinger/FastMixerDumpState.cpp b/services/audioflinger/FastMixerDumpState.cpp index 87eaacb..386b29d 100644 --- a/services/audioflinger/FastMixerDumpState.cpp +++ b/services/audioflinger/FastMixerDumpState.cpp @@ -62,34 +62,6 @@ void FastMixerDumpState::dump(int fd) const dprintf(fd, " FastMixer not initialized\n"); return; } -#define COMMAND_MAX 32 - char string[COMMAND_MAX]; - switch (mCommand) { - case FastMixerState::INITIAL: - strcpy(string, "INITIAL"); - break; - case FastMixerState::HOT_IDLE: - strcpy(string, "HOT_IDLE"); - break; - case FastMixerState::COLD_IDLE: - strcpy(string, "COLD_IDLE"); - break; - case FastMixerState::EXIT: - strcpy(string, "EXIT"); - break; - case FastMixerState::MIX: - strcpy(string, "MIX"); - break; - case FastMixerState::WRITE: - strcpy(string, "WRITE"); - break; - case FastMixerState::MIX_WRITE: - strcpy(string, "MIX_WRITE"); - break; - default: - snprintf(string, COMMAND_MAX, "%d", mCommand); - break; - } double measuredWarmupMs = (mMeasuredWarmupTs.tv_sec * 1000.0) + (mMeasuredWarmupTs.tv_nsec / 1000000.0); double mixPeriodSec = (double) mFrameCount / (double) mSampleRate; @@ -97,7 +69,7 @@ void FastMixerDumpState::dump(int fd) const " numTracks=%u writeErrors=%u underruns=%u overruns=%u\n" " sampleRate=%u frameCount=%zu measuredWarmup=%.3g ms, warmupCycles=%u\n" " mixPeriod=%.2f ms\n", - string, mWriteSequence, mFramesWritten, + FastMixerState::commandToString(mCommand), mWriteSequence, mFramesWritten, mNumTracks, mWriteErrors, mUnderruns, mOverruns, mSampleRate, mFrameCount, measuredWarmupMs, mWarmupCycles, mixPeriodSec * 1e3); diff --git a/services/audioflinger/FastMixerState.cpp b/services/audioflinger/FastMixerState.cpp index 3aa8dad..a8c2634 100644 --- a/services/audioflinger/FastMixerState.cpp +++ b/services/audioflinger/FastMixerState.cpp @@ -39,4 +39,19 @@ FastMixerState::~FastMixerState() { } +// static +const char *FastMixerState::commandToString(Command command) +{ + const char *str = FastThreadState::commandToString(command); + if (str != NULL) { + return str; + } + switch (command) { + case FastMixerState::MIX: return "MIX"; + case FastMixerState::WRITE: return "WRITE"; + case FastMixerState::MIX_WRITE: return "MIX_WRITE"; + } + LOG_ALWAYS_FATAL("%s", __func__); +} + } // namespace android diff --git a/services/audioflinger/FastMixerState.h b/services/audioflinger/FastMixerState.h index 661c9ca..916514f 100644 --- a/services/audioflinger/FastMixerState.h +++ b/services/audioflinger/FastMixerState.h @@ -73,6 +73,9 @@ struct FastMixerState : FastThreadState { // This might be a one-time configuration rather than per-state NBAIO_Sink* mTeeSink; // if non-NULL, then duplicate write()s to this non-blocking sink + + // never returns NULL; asserts if command is invalid + static const char *commandToString(Command command); }; // struct FastMixerState } // namespace android diff --git a/services/audioflinger/FastThreadState.cpp b/services/audioflinger/FastThreadState.cpp index e6cf85c..ad5f31f 100644 --- a/services/audioflinger/FastThreadState.cpp +++ b/services/audioflinger/FastThreadState.cpp @@ -29,4 +29,16 @@ FastThreadState::~FastThreadState() { } +// static +const char *FastThreadState::commandToString(FastThreadState::Command command) +{ + switch (command) { + case FastThreadState::INITIAL: return "INITIAL"; + case FastThreadState::HOT_IDLE: return "HOT_IDLE"; + case FastThreadState::COLD_IDLE: return "COLD_IDLE"; + case FastThreadState::EXIT: return "EXIT"; + } + return NULL; +} + } // namespace android diff --git a/services/audioflinger/FastThreadState.h b/services/audioflinger/FastThreadState.h index 011921d..f18f846 100644 --- a/services/audioflinger/FastThreadState.h +++ b/services/audioflinger/FastThreadState.h @@ -46,6 +46,8 @@ struct FastThreadState { FastThreadDumpState* mDumpState; // if non-NULL, then update dump state periodically NBLog::Writer* mNBLogWriter; // non-blocking logger + // returns NULL if command belongs to a subclass + static const char *commandToString(Command command); }; // struct FastThreadState } // android |