Home | History | Annotate | Download | only in devices
      1 page.title=Audio Warmup
      2 @jd:body
      3 
      4 <!--
      5     Copyright 2010 The Android Open Source Project
      6 
      7     Licensed under the Apache License, Version 2.0 (the "License");
      8     you may not use this file except in compliance with the License.
      9     You may obtain a copy of the License at
     10 
     11         http://www.apache.org/licenses/LICENSE-2.0
     12 
     13     Unless required by applicable law or agreed to in writing, software
     14     distributed under the License is distributed on an "AS IS" BASIS,
     15     WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
     16     See the License for the specific language governing permissions and
     17     limitations under the License.
     18 -->
     19 <div id="qv-wrapper">
     20   <div id="qv">
     21     <h2>In this document</h2>
     22     <ol id="auto-toc">
     23     </ol>
     24   </div>
     25 </div>
     26 
     27 <p>Audio warmup is the time for the audio amplifier circuit in your device to
     28 be fully powered and reach its normal operation state. The major contributors
     29 to audio warmup time are power management and any "de-pop" logic to stabilize
     30 the circuit.
     31 </p>
     32 
     33 <p>This document describes how to measure audio warmup time and possible ways to decrease
     34 warmup time.</p>
     35 
     36 <h2 id="measuringOutput">Measuring Output Warmup</h2>
     37 
     38 <p>
     39   AudioFlinger's FastMixer thread automatically measures output warmup
     40   and reports it as part of the output of the <code>dumpsys media.audio_flinger</code> command.
     41   At warmup, FastMixer calls <code>write()</code>
     42   repeatedly until the time between two <code>write()</code>s is the amount expected.
     43   FastMixer determines audio warmup by seeing how long a HAL <code>write()</code> takes to stabilize. 
     44 </p>
     45 
     46 <p>To measure audio warmup, do the following
     47 steps for the built-in speaker and wired headphones and at different times after booting.
     48 Warmup times are usually different for each output device and right after booting the device:</p>
     49 
     50 <ol>
     51   <li>Ensure that FastMixer is enabled.</li>
     52   <li>Enable touch sounds by selecting <b>Settings > Sound > Touch sounds</b> on the device.</li>
     53   <li>Ensure that audio has been off for at least three seconds. Five seconds or more is better, because
     54   the hardware itself might have its own power logic beyond the three seconds that AudioFlinger has.</li>
     55   <li>Press Home, and you should hear a click sound.</li>
     56   <li>Run the following command to receive the measured warmup:
     57   <pre>adb shell dumpsys media.audio_flinger | grep measuredWarmup</code></pre>
     58 
     59 <p>
     60 You should see output like this:
     61 </p>
     62 
     63 <pre>
     64 sampleRate=44100 frameCount=256 measuredWarmup=X ms, warmupCycles=X
     65 </pre>
     66 
     67 <p>
     68   The <code>measuredWarmup=X</code> is X number of milliseconds
     69   it took for the first set of HAL <code>write()</code>s to complete.
     70 </p>
     71 
     72 <p>
     73   The <code>warmupCycles=X</code> is how many HAL write requests it took
     74   until the execution time of <code>write()</code> matches what is expected.
     75 </p>
     76 </li>
     77 <li>
     78   Take five measurements and report them all, as well as the mean.
     79   If they are not all approximately the same,
     80   then its likely that a measurement is incorrect.
     81   For example, if you dont wait long enough after the audio has been off,
     82   you will see a lower warmup time than the mean value.
     83 </li>
     84 </ol>
     85 
     86 
     87 <h2 id="measuringInput">Measuring Input Warmup</h2>
     88 
     89 <p>
     90   There are currently no tools provided for measuring audio input warmup.
     91   However, input warmup time can be estimated by observing
     92   the time required for <a href="http://developer.android.com/reference/android/media/AudioRecord.html#startRecording()">startRecording()</a>
     93   to return. 
     94 </p>
     95 
     96 
     97 <h2 id="reducing">Reducing Warmup Time</h2>
     98 
     99 <p>
    100   Warmup time can usually be reduced by a combination of:
    101   <ul>
    102   <li>Good circuit design</li>
    103   <li>Accurate time delays in kernel device driver</li>
    104   <li>Performing independent warmup operations concurrently rather than sequentially</li>
    105   <li>Leaving circuits powered on or not reconfiguring clocks (increases idle power consumption).
    106   <li>Caching computed parameters</li>
    107   </ul>
    108   However, beware of excessive optimization. You may find that you
    109   need to tradeoff between low warmup time versus
    110   lack of popping at power transitions.
    111 </p>
    112