In this document
Audio warmup is the time for the audio amplifier circuit in your device to be fully powered and reach its normal operation state. The major contributors to audio warmup time are power management and any "de-pop" logic to stabilize the circuit.
This document describes how to measure audio warmup time and possible ways to decrease warmup time.
Measuring Output Warmup
AudioFlinger's FastMixer thread automatically measures output warmup
and reports it as part of the output of the
dumpsys media.audio_flinger command.
At warmup, FastMixer calls
repeatedly until the time between two
write()s is the amount expected.
FastMixer determines audio warmup by seeing how long a Hardware Abstraction
write() takes to stabilize.
To measure audio warmup, follow these steps for the built-in speaker and wired headphones and at different times after booting. Warmup times are usually different for each output device and right after booting the device:
- Ensure that FastMixer is enabled.
- Enable touch sounds by selecting Settings > Sound > Touch sounds on the device.
- Ensure that audio has been off for at least three seconds. Five seconds or more is better, because the hardware itself might have its own power logic beyond the three seconds that AudioFlinger has.
- Press Home, and you should hear a click sound.
- Run the following command to receive the measured warmup:
adb shell dumpsys media.audio_flinger | grep measuredWarmup
You should see output like this:
sampleRate=44100 frameCount=256 measuredWarmup=X ms, warmupCycles=X
measuredWarmup=Xis X number of milliseconds it took for the first set of HAL
write()s to complete.
warmupCycles=Xis how many HAL write requests it took until the execution time of
write()matches what is expected.
- Take five measurements and record them all, as well as the mean. If they are not all approximately the same, then it's likely that a measurement is incorrect. For example, if you don't wait long enough after the audio has been off, you will see a lower warmup time than the mean value.
Measuring Input Warmup
There are currently no tools provided for measuring audio input warmup. However, input warmup time can be estimated by observing the time required for startRecording() to return.
Reducing Warmup Time
Warmup time can usually be reduced by a combination of:
- Good circuit design
- Accurate time delays in kernel device driver
- Performing independent warmup operations concurrently rather than sequentially
- Leaving circuits powered on or not reconfiguring clocks (increases idle power consumption)
- Caching computed parameters
However, beware of excessive optimization. You may find that you need to tradeoff between low warmup time versus lack of popping at power transitions.