blob: 777650b83ce98ca0e99e6427539967664da71227 [file] [log] [blame]
page.title=Audio Warmup
Copyright 2013 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
See the License for the specific language governing permissions and
limitations under the License.
<div id="qv-wrapper">
<div id="qv">
<h2>In this document</h2>
<ol id="auto-toc">
<p>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.
<p>This document describes how to measure audio warmup time and possible ways to decrease
warmup time.</p>
<h2 id="measuringOutput">Measuring Output Warmup</h2>
AudioFlinger's FastMixer thread automatically measures output warmup
and reports it as part of the output of the <code>dumpsys media.audio_flinger</code> command.
At warmup, FastMixer calls <code>write()</code>
repeatedly until the time between two <code>write()</code>s is the amount expected.
FastMixer determines audio warmup by seeing how long a Hardware Abstraction
Layer (HAL) <code>write()</code> takes to stabilize.
<p>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:</p>
<li>Ensure that FastMixer is enabled.</li>
<li>Enable touch sounds by selecting <b>Settings > Sound > Touch sounds</b> on the device.</li>
<li>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.</li>
<li>Press Home, and you should hear a click sound.</li>
<li>Run the following command to receive the measured warmup:
<br /><code>adb shell dumpsys media.audio_flinger | grep measuredWarmup</code>
You should see output like this:
sampleRate=44100 frameCount=256 measuredWarmup=X ms, warmupCycles=X
The <code>measuredWarmup=X</code> is X number of milliseconds
it took for the first set of HAL <code>write()</code>s to complete.
The <code>warmupCycles=X</code> is how many HAL write requests it took
until the execution time of <code>write()</code> 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.
<h2 id="measuringInput">Measuring Input Warmup</h2>
There are currently no tools provided for measuring audio input warmup.
However, input warmup time can be estimated by observing
the time required for <a href="">startRecording()</a>
to return.
<h2 id="reducing">Reducing Warmup Time</h2>
Warmup time can usually be reduced by a combination of:
<li>Good circuit design</li>
<li>Accurate time delays in kernel device driver</li>
<li>Performing independent warmup operations concurrently rather than sequentially</li>
<li>Leaving circuits powered on or not reconfiguring clocks (increases idle power consumption)
<li>Caching computed parameters</li>
However, beware of excessive optimization. You may find that you
need to tradeoff between low warmup time versus
lack of popping at power transitions.