blob: 0a0ec04684cf4ba2961c629b553b391266cf5ccc [file] [log] [blame]
Robert Ly35f2fda2013-01-29 16:27:05 -08001page.title=Audio Warmup
2@jd:body
3
4<!--
Clay Murphy768b82a2013-11-12 11:32:41 -08005 Copyright 2013 The Android Open Source Project
Robert Ly35f2fda2013-01-29 16:27:05 -08006
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
28be fully powered and reach its normal operation state. The major contributors
29to audio warmup time are power management and any "de-pop" logic to stabilize
30the circuit.
31</p>
32
33<p>This document describes how to measure audio warmup time and possible ways to decrease
34warmup 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.
Clay Murphyc28f2372013-09-25 16:13:40 -070043 FastMixer determines audio warmup by seeing how long a Hardware Abstraction
44Layer (HAL) <code>write()</code> takes to stabilize.
Robert Ly35f2fda2013-01-29 16:27:05 -080045</p>
46
Clay Murphyc28f2372013-09-25 16:13:40 -070047<p>To measure audio warmup, follow these steps for the built-in speaker and wired headphones
48 and at different times after booting. Warmup times are usually different for each output device
49 and right after booting the device:</p>
Robert Ly35f2fda2013-01-29 16:27:05 -080050
51<ol>
52 <li>Ensure that FastMixer is enabled.</li>
53 <li>Enable touch sounds by selecting <b>Settings > Sound > Touch sounds</b> on the device.</li>
54 <li>Ensure that audio has been off for at least three seconds. Five seconds or more is better, because
55 the hardware itself might have its own power logic beyond the three seconds that AudioFlinger has.</li>
56 <li>Press Home, and you should hear a click sound.</li>
57 <li>Run the following command to receive the measured warmup:
Glenn Kasten795a9de2014-01-24 08:58:56 -080058 <br /><code>adb shell dumpsys media.audio_flinger | grep measuredWarmup</code>
Robert Ly35f2fda2013-01-29 16:27:05 -080059
60<p>
61You should see output like this:
62</p>
63
64<pre>
65sampleRate=44100 frameCount=256 measuredWarmup=X ms, warmupCycles=X
66</pre>
67
68<p>
69 The <code>measuredWarmup=X</code> is X number of milliseconds
70 it took for the first set of HAL <code>write()</code>s to complete.
71</p>
72
73<p>
74 The <code>warmupCycles=X</code> is how many HAL write requests it took
75 until the execution time of <code>write()</code> matches what is expected.
76</p>
77</li>
78<li>
Clay Murphyc28f2372013-09-25 16:13:40 -070079 Take five measurements and record them all, as well as the mean.
Robert Ly35f2fda2013-01-29 16:27:05 -080080 If they are not all approximately the same,
Glenn Kasten795a9de2014-01-24 08:58:56 -080081 then it's likely that a measurement is incorrect.
82 For example, if you don't wait long enough after the audio has been off,
Robert Ly35f2fda2013-01-29 16:27:05 -080083 you will see a lower warmup time than the mean value.
84</li>
85</ol>
86
87
88<h2 id="measuringInput">Measuring Input Warmup</h2>
89
90<p>
91 There are currently no tools provided for measuring audio input warmup.
92 However, input warmup time can be estimated by observing
93 the time required for <a href="http://developer.android.com/reference/android/media/AudioRecord.html#startRecording()">startRecording()</a>
94 to return.
95</p>
96
97
98<h2 id="reducing">Reducing Warmup Time</h2>
99
100<p>
101 Warmup time can usually be reduced by a combination of:
102 <ul>
103 <li>Good circuit design</li>
104 <li>Accurate time delays in kernel device driver</li>
105 <li>Performing independent warmup operations concurrently rather than sequentially</li>
Clay Murphyc28f2372013-09-25 16:13:40 -0700106 <li>Leaving circuits powered on or not reconfiguring clocks (increases idle power consumption)
Robert Ly35f2fda2013-01-29 16:27:05 -0800107 <li>Caching computed parameters</li>
108 </ul>
Glenn Kasten795a9de2014-01-24 08:58:56 -0800109<p>
Robert Ly35f2fda2013-01-29 16:27:05 -0800110 However, beware of excessive optimization. You may find that you
111 need to tradeoff between low warmup time versus
112 lack of popping at power transitions.
113</p>