Starting March 27, 2025, we recommend using android-latest-release
instead of aosp-main
to build and contribute to AOSP. For more information, see Changes to AOSP.
Audio warmup
Stay organized with collections
Save and categorize content based on your preferences.
Audio warmup is the time it takes 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.
Measure 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 write()
repeatedly until the time between two write()
s is the amount expected.
FastMixer determines audio warmup by seeing how long a Hardware Abstraction
Layer (HAL) 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
The measuredWarmup=X
is X number of milliseconds
it took for the first set of HAL write()
s to complete.
The warmupCycles=X
is 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.
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.
Reduce 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.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2024-08-26 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-08-26 UTC."],[],[],null,["# Audio warmup is the time it takes for the audio amplifier circuit in your device to\nbe fully powered and reach its normal operation state. The major contributors\nto audio warmup time are power management and any \"de-pop\" logic to stabilize\nthe circuit.\n\nThis document describes how to measure audio warmup time and possible ways to decrease\nwarmup time.\n\nMeasure output warmup\n---------------------\n\n\nAudioFlinger's FastMixer thread automatically measures output warmup\nand reports it as part of the output of the `dumpsys media.audio_flinger` command.\nAt warmup, FastMixer calls `write()`\nrepeatedly until the time between two `write()`s is the amount expected.\nFastMixer determines audio warmup by seeing how long a Hardware Abstraction\nLayer (HAL) `write()` takes to stabilize.\n\nTo measure audio warmup, follow these steps for the built-in speaker and wired headphones\nand at different times after booting. Warmup times are usually different for each output device\nand right after booting the device:\n\n1. Ensure that FastMixer is enabled.\n2. Enable touch sounds by selecting **Settings \\\u003e Sound \\\u003e Touch sounds** on the device.\n3. 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.\n4. Press Home, and you should hear a click sound.\n5. Run the following command to receive the measured warmup: \n\n ```\n adb shell dumpsys media.audio_flinger | grep measuredWarmup\n ```\n\n\n You should see output like this: \n\n ```\n sampleRate=44100 frameCount=256 measuredWarmup=X ms, warmupCycles=X\n ```\n\n\n The `measuredWarmup=X` is X number of milliseconds\n it took for the first set of HAL `write()`s to complete.\n\n\n The `warmupCycles=X` is how many HAL write requests it took\n until the execution time of `write()` matches what is expected.\n6. 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.\n\nMeasure input warmup\n--------------------\n\n\nThere are currently no tools provided for measuring audio input warmup.\nHowever, input warmup time can be estimated by observing\nthe time required for [startRecording()](http://developer.android.com/reference/android/media/AudioRecord.html#startRecording())\nto return.\n\nReduce warmup time\n------------------\n\n\nWarmup time can usually be reduced by a combination of:\n\n- Good circuit design\n- Accurate time delays in kernel device driver\n- Performing independent warmup operations concurrently rather than sequentially\n- Leaving circuits powered on or not reconfiguring clocks (increases idle power consumption)\n- Caching computed parameters\n\n\nHowever, beware of excessive optimization. You may find that you\nneed to tradeoff between low warmup time versus\nlack of popping at power transitions."]]