summaryrefslogtreecommitdiffstats
path: root/services/audioflinger/FastMixer.cpp
diff options
context:
space:
mode:
authorGlenn Kasten <gkasten@google.com>2012-06-13 14:59:07 -0700
committerGlenn Kasten <gkasten@google.com>2012-06-15 14:53:31 -0700
commiteb15716b59020f342df62bce5b293f0603b94861 (patch)
treed230ab42f45394837dffc52deb8d31c8fef9c1c1 /services/audioflinger/FastMixer.cpp
parent972af221ae7253e406e0e1ea853e56a3010ed6b1 (diff)
downloadframeworks_av-eb15716b59020f342df62bce5b293f0603b94861.zip
frameworks_av-eb15716b59020f342df62bce5b293f0603b94861.tar.gz
frameworks_av-eb15716b59020f342df62bce5b293f0603b94861.tar.bz2
Change definition of warmup period
Previously, warmup was considered done as soon as any write() took more than 0.5 nominal cycle time. In practice, this was always the first write() that turned on power to the output path, and it didn't accurately account for filling the full kernel buffer queue, or for buffering in the HAL sample rate conversion. Now warmup is considered done when a write() _after_ the first write takes more than 0.5 nominal cycle time. This will throttle the initial pull rate after coming out of standby. When combined with another change to throttle the pull rate for devices with HAL sample rate conversion, it may help reduce some of the notification glitches. The only downside is that it will increase the warmup time a bit. Bug: 6508317, 6650846, 6607056 Change-Id: I39f324c5195578170a55308e9601d3a1b41db3e0
Diffstat (limited to 'services/audioflinger/FastMixer.cpp')
-rw-r--r--services/audioflinger/FastMixer.cpp7
1 files changed, 5 insertions, 2 deletions
diff --git a/services/audioflinger/FastMixer.cpp b/services/audioflinger/FastMixer.cpp
index 2c5d751..7652132 100644
--- a/services/audioflinger/FastMixer.cpp
+++ b/services/audioflinger/FastMixer.cpp
@@ -33,6 +33,7 @@
#define FAST_HOT_IDLE_NS 1000000L // 1 ms: time to sleep while hot idling
#define FAST_DEFAULT_NS 999999999L // ~1 sec: default time to sleep
+#define MIN_WARMUP_CYCLES 2 // minimum number of loop cycles to wait for warmup
#define MAX_WARMUP_CYCLES 10 // maximum number of loop cycles to wait for warmup
namespace android {
@@ -454,7 +455,7 @@ bool FastMixer::threadLoop()
// To avoid an initial underrun on fast tracks after exiting standby,
// do not start pulling data from tracks and mixing until warmup is complete.
// Warmup is considered complete after the earlier of:
- // first successful single write() that blocks for more than warmupNs
+ // MIN_WARMUP_CYCLES write() attempts and last one blocks for at least warmupNs
// MAX_WARMUP_CYCLES write() attempts.
// This is overly conservative, but to get better accuracy requires a new HAL API.
if (!isWarm && attemptedWrite) {
@@ -465,7 +466,7 @@ bool FastMixer::threadLoop()
measuredWarmupTs.tv_nsec -= 1000000000;
}
++warmupCycles;
- if ((attemptedWrite && nsec > warmupNs) ||
+ if ((nsec > warmupNs && warmupCycles >= MIN_WARMUP_CYCLES) ||
(warmupCycles >= MAX_WARMUP_CYCLES)) {
isWarm = true;
dumpState->mMeasuredWarmupTs = measuredWarmupTs;
@@ -504,6 +505,7 @@ bool FastMixer::threadLoop()
}
}
#ifdef FAST_MIXER_STATISTICS
+ if (isWarm) {
// advance the FIFO queue bounds
size_t i = bounds & (FastMixerDumpState::kSamplingN - 1);
bounds = (bounds & 0xFFFF0000) | ((bounds + 1) & 0xFFFF);
@@ -560,6 +562,7 @@ bool FastMixer::threadLoop()
ATRACE_INT("cycle_ms", monotonicNs / 1000000);
ATRACE_INT("load_us", loadNs / 1000);
#endif
+ }
#endif
} else {
// first time through the loop