summaryrefslogtreecommitdiffstats
path: root/services
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2015-03-02 14:47:19 -0800
committerGlenn Kasten <gkasten@google.com>2015-03-03 08:50:40 -0800
commitfbdb2aceab7317aa44bc8f301a93eb49e17b2bce (patch)
tree97defd36379d3d4770dbd02dbacf046084889761 /services
parent63238efb0d674758902918e3cdaac322126484b7 (diff)
downloadframeworks_av-fbdb2aceab7317aa44bc8f301a93eb49e17b2bce.zip
frameworks_av-fbdb2aceab7317aa44bc8f301a93eb49e17b2bce.tar.gz
frameworks_av-fbdb2aceab7317aa44bc8f301a93eb49e17b2bce.tar.bz2
Pull up increaseSamplingN and kSamplingNforLowRamDevice
from FastMixerDumpState to FastThreadDumpState, and remove unused parameter from FastMixerDumpState constructor. Change-Id: Ib8937b106622a8da28a6ef6043de4528ae82cb05
Diffstat (limited to 'services')
-rw-r--r--services/audioflinger/FastMixerDumpState.cpp27
-rw-r--r--services/audioflinger/FastMixerDumpState.h14
-rw-r--r--services/audioflinger/FastThreadDumpState.cpp23
-rw-r--r--services/audioflinger/FastThreadDumpState.h6
-rw-r--r--services/audioflinger/Threads.cpp6
5 files changed, 33 insertions, 43 deletions
diff --git a/services/audioflinger/FastMixerDumpState.cpp b/services/audioflinger/FastMixerDumpState.cpp
index 148c0f7..87eaacb 100644
--- a/services/audioflinger/FastMixerDumpState.cpp
+++ b/services/audioflinger/FastMixerDumpState.cpp
@@ -30,39 +30,14 @@
namespace android {
-FastMixerDumpState::FastMixerDumpState(
-#ifdef FAST_THREAD_STATISTICS
- uint32_t samplingN
-#endif
- ) : FastThreadDumpState(),
+FastMixerDumpState::FastMixerDumpState() : FastThreadDumpState(),
mWriteSequence(0), mFramesWritten(0),
mNumTracks(0), mWriteErrors(0),
mSampleRate(0), mFrameCount(0),
mTrackMask(0)
{
-#ifdef FAST_THREAD_STATISTICS
- increaseSamplingN(samplingN);
-#endif
}
-#ifdef FAST_THREAD_STATISTICS
-void FastMixerDumpState::increaseSamplingN(uint32_t samplingN)
-{
- if (samplingN <= mSamplingN || samplingN > kSamplingN || roundup(samplingN) != samplingN) {
- return;
- }
- uint32_t additional = samplingN - mSamplingN;
- // sample arrays aren't accessed atomically with respect to the bounds,
- // so clearing reduces chance for dumpsys to read random uninitialized samples
- memset(&mMonotonicNs[mSamplingN], 0, sizeof(mMonotonicNs[0]) * additional);
- memset(&mLoadNs[mSamplingN], 0, sizeof(mLoadNs[0]) * additional);
-#ifdef CPU_FREQUENCY_STATISTICS
- memset(&mCpukHz[mSamplingN], 0, sizeof(mCpukHz[0]) * additional);
-#endif
- mSamplingN = samplingN;
-}
-#endif
-
FastMixerDumpState::~FastMixerDumpState()
{
}
diff --git a/services/audioflinger/FastMixerDumpState.h b/services/audioflinger/FastMixerDumpState.h
index bd475d6..d958bf4 100644
--- a/services/audioflinger/FastMixerDumpState.h
+++ b/services/audioflinger/FastMixerDumpState.h
@@ -66,11 +66,7 @@ struct FastTrackDump {
// Only POD types are permitted, and the contents shouldn't be trusted (i.e. do range checks).
// It has a different lifetime than the FastMixer, and so it can't be a member of FastMixer.
struct FastMixerDumpState : FastThreadDumpState {
- FastMixerDumpState(
-#ifdef FAST_THREAD_STATISTICS
- uint32_t samplingN = kSamplingNforLowRamDevice
-#endif
- );
+ FastMixerDumpState();
/*virtual*/ ~FastMixerDumpState();
void dump(int fd) const; // should only be called on a stable copy, not the original
@@ -83,14 +79,6 @@ struct FastMixerDumpState : FastThreadDumpState {
size_t mFrameCount;
uint32_t mTrackMask; // mask of active tracks
FastTrackDump mTracks[FastMixerState::kMaxFastTracks];
-
-#ifdef FAST_THREAD_STATISTICS
- // Compile-time constant for a "low RAM device", must be a power of 2 <= kSamplingN.
- // This value was chosen such that each array uses 1 small page (4 Kbytes).
- static const uint32_t kSamplingNforLowRamDevice = 0x400;
- // Increase sampling window after construction, must be a power of 2 <= kSamplingN
- void increaseSamplingN(uint32_t samplingN);
-#endif
};
} // android
diff --git a/services/audioflinger/FastThreadDumpState.cpp b/services/audioflinger/FastThreadDumpState.cpp
index 9d575a6..9df5c4c 100644
--- a/services/audioflinger/FastThreadDumpState.cpp
+++ b/services/audioflinger/FastThreadDumpState.cpp
@@ -23,15 +23,36 @@ FastThreadDumpState::FastThreadDumpState() :
/* mMeasuredWarmupTs({0, 0}), */
mWarmupCycles(0)
#ifdef FAST_THREAD_STATISTICS
- , mSamplingN(1), mBounds(0)
+ , mSamplingN(0), mBounds(0)
#endif
{
mMeasuredWarmupTs.tv_sec = 0;
mMeasuredWarmupTs.tv_nsec = 0;
+#ifdef FAST_THREAD_STATISTICS
+ increaseSamplingN(1);
+#endif
}
FastThreadDumpState::~FastThreadDumpState()
{
}
+#ifdef FAST_THREAD_STATISTICS
+void FastThreadDumpState::increaseSamplingN(uint32_t samplingN)
+{
+ if (samplingN <= mSamplingN || samplingN > kSamplingN || roundup(samplingN) != samplingN) {
+ return;
+ }
+ uint32_t additional = samplingN - mSamplingN;
+ // sample arrays aren't accessed atomically with respect to the bounds,
+ // so clearing reduces chance for dumpsys to read random uninitialized samples
+ memset(&mMonotonicNs[mSamplingN], 0, sizeof(mMonotonicNs[0]) * additional);
+ memset(&mLoadNs[mSamplingN], 0, sizeof(mLoadNs[0]) * additional);
+#ifdef CPU_FREQUENCY_STATISTICS
+ memset(&mCpukHz[mSamplingN], 0, sizeof(mCpukHz[0]) * additional);
+#endif
+ mSamplingN = samplingN;
+}
+#endif
+
} // android
diff --git a/services/audioflinger/FastThreadDumpState.h b/services/audioflinger/FastThreadDumpState.h
index 67468b9..bbca7da 100644
--- a/services/audioflinger/FastThreadDumpState.h
+++ b/services/audioflinger/FastThreadDumpState.h
@@ -39,6 +39,9 @@ struct FastThreadDumpState {
// The sample arrays are virtually allocated based on this compile-time constant,
// but are only initialized and used based on the runtime parameter mSamplingN.
static const uint32_t kSamplingN = 0x8000;
+ // Compile-time constant for a "low RAM device", must be a power of 2 <= kSamplingN.
+ // This value was chosen such that each array uses 1 small page (4 Kbytes).
+ static const uint32_t kSamplingNforLowRamDevice = 0x400;
// Corresponding runtime maximum size of sample arrays, must be a power of 2 <= kSamplingN.
uint32_t mSamplingN;
// The bounds define the interval of valid samples, and are represented as follows:
@@ -52,6 +55,9 @@ struct FastThreadDumpState {
#ifdef CPU_FREQUENCY_STATISTICS
uint32_t mCpukHz[kSamplingN]; // absolute CPU clock frequency in kHz, bits 0-3 are CPU#
#endif
+
+ // Increase sampling window after construction, must be a power of 2 <= kSamplingN
+ void increaseSamplingN(uint32_t samplingN);
#endif
}; // struct FastThreadDumpState
diff --git a/services/audioflinger/Threads.cpp b/services/audioflinger/Threads.cpp
index 971a3b8..7451245 100644
--- a/services/audioflinger/Threads.cpp
+++ b/services/audioflinger/Threads.cpp
@@ -3118,7 +3118,7 @@ ssize_t AudioFlinger::MixerThread::threadLoop_write()
state->mCommand = FastMixerState::MIX_WRITE;
#ifdef FAST_THREAD_STATISTICS
mFastMixerDumpState.increaseSamplingN(mAudioFlinger->isLowRamDevice() ?
- FastMixerDumpState::kSamplingNforLowRamDevice : FastMixerDumpState::kSamplingN);
+ FastThreadDumpState::kSamplingNforLowRamDevice : FastThreadDumpState::kSamplingN);
#endif
sq->end();
sq->push(FastMixerStateQueue::BLOCK_UNTIL_PUSHED);
@@ -5388,8 +5388,8 @@ reacquire_wakelock:
state->mCommand = FastCaptureState::READ_WRITE;
#if 0 // FIXME
mFastCaptureDumpState.increaseSamplingN(mAudioFlinger->isLowRamDevice() ?
- FastCaptureDumpState::kSamplingNforLowRamDevice :
- FastMixerDumpState::kSamplingN);
+ FastThreadDumpState::kSamplingNforLowRamDevice :
+ FastThreadDumpState::kSamplingN);
#endif
didModify = true;
}