summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/FastMixer.cpp
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2012-05-14 17:41:09 -0700
committerGlenn Kasten <gkasten@google.com>2012-05-17 15:01:45 -0700
commitc059bd4246c1b3944965be921e5b334d51cd236c (patch)
treed1c5ee08f63985bc15c2d4ad9025ee6631667663 /services/audioflinger/FastMixer.cpp
parente00e0485b0aa1e432be8c639da0eb5285942777b (diff)
downloadframeworks_av-c059bd4246c1b3944965be921e5b334d51cd236c.zip
frameworks_av-c059bd4246c1b3944965be921e5b334d51cd236c.tar.gz
frameworks_av-c059bd4246c1b3944965be921e5b334d51cd236c.tar.bz2
Skip bad kHz values, and display them accurately
One device reports zero CPU kHz occasionally, so skip those values. Preserve accuracy of the low-order 4 bits of the the CPU frequency. Change-Id: I7d934f697412277462464fca82d112d0306a214e
Diffstat (limited to 'services/audioflinger/FastMixer.cpp')
-rw-r--r--services/audioflinger/FastMixer.cpp15
1 files changed, 9 insertions, 6 deletions
diff --git a/services/audioflinger/FastMixer.cpp b/services/audioflinger/FastMixer.cpp
index cd55396..e73257e 100644
--- a/services/audioflinger/FastMixer.cpp
+++ b/services/audioflinger/FastMixer.cpp
@@ -508,7 +508,7 @@ bool FastMixer::threadLoop()
// get the absolute value of CPU clock frequency in kHz
int cpuNum = sched_getcpu();
uint32_t kHz = tcu.getCpukHz(cpuNum);
- kHz = (kHz & ~0xF) | (cpuNum & 0xF);
+ kHz = (kHz << 4) | (cpuNum & 0xF);
// save values in FIFO queues for dumpsys
// these stores #1, #2, #3 are not atomic with respect to each other,
// or with respect to store #4 below
@@ -624,11 +624,14 @@ void FastMixerDumpState::dump(int fd)
uint32_t sampleLoadNs = mLoadNs[i];
uint32_t sampleCpukHz = mCpukHz[i];
loadNs.sample(sampleLoadNs);
- kHz.sample(sampleCpukHz & ~0xF);
- if (sampleCpukHz == previousCpukHz) {
- double megacycles = (double) sampleLoadNs * (double) sampleCpukHz * 1e-12;
- double adjMHz = megacycles / mixPeriodSec; // _not_ wallNs * 1e9
- loadMHz.sample(adjMHz);
+ // skip bad kHz samples
+ if ((sampleCpukHz & ~0xF) != 0) {
+ kHz.sample(sampleCpukHz >> 4);
+ if (sampleCpukHz == previousCpukHz) {
+ double megacycles = (double) sampleLoadNs * (double) (sampleCpukHz >> 4) * 1e-12;
+ double adjMHz = megacycles / mixPeriodSec; // _not_ wallNs * 1e9
+ loadMHz.sample(adjMHz);
+ }
}
previousCpukHz = sampleCpukHz;
}