自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
音频延迟测量
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
延迟时间是一项重要的系统性能指标。音频延迟时间指标有多种类型,其中一个很实用且易于理解的指标是往返延迟时间。根据该指标的定义,往返延迟时间是指音频信号进入移动设备的输入组件,由应用处理器上运行的应用进行处理,然后从输出组件传出的整个过程所花费的时间。
图 1. 设备上的往返音频延迟时间:Toutput - Tinput
本页提供了选定 Nexus/Pixel 设备和 Android 平台版本的往返音频延迟时间测量结果。
为什么要测量延迟时间
Google 会测量和报告延迟时间,以便 Android 应用开发者获取所需数据,从而针对实际设备上的可用延迟时间做出明智决策。我们会分享选定 Nexus 和 Pixel 设备的延迟时间数值,以此鼓励整个 Android 社区的成员来测量、发布和减少所有 Android 设备上的延迟时间。欢迎加入我们,一起为减少音频延迟时间而努力!
应用对延迟时间的影响
信号处理技术可能会在延迟时间中添加以下类型的延迟:
- 算法。这是一种固有延迟,不会因 CPU 而异。例如,由有限脉冲响应 (FIR) 过滤器增加的延迟。
- 计算。这种延迟与所需的 CPU 周期数有关。例如,信号的衰减通常通过乘法运算完成,而该运算所需的周期数则取决于 CPU。
如何测量
我们使用 Dr. Rick O'Rang 音频环回加密狗和音频反馈(拉尔森效应)测试得出了本页列出的测量结果。测量假设应用信号处理的算法延迟时间为零,并且计算延迟时间接近零。
我们通过耳机连接器来测量往返延迟时间有以下几个原因:
图 2. 通过耳机连接器测量的往返延迟时间:Toutput - Tinput
- 重要的音乐应用(如吉他和语音处理)一般会使用耳机连接器。
- 测量设备上的麦克风和扬声器之间的往返延迟时间可能会比较麻烦,因为在露天环境下难以避免反馈环进入不受控制的振荡状态。
- 设备上的换能器都很小,为了实现它们的小尺寸则需要牺牲频率响应。出于补偿目的,换能器会应用数字信号处理技术,但这会增加设备上路径的算法延迟时间。
在有些情况下,设备上的麦克风和扬声器延迟时间确实会带来影响,但这通常是针对单向延迟而不是往返延迟。测量输出设备延迟时间和测量输入设备延迟时间中介绍了测量单向延迟时间的相关技巧。
测量结果示例
下面列出的是特定于某个版本号的测量结果。设备按初始版本和平台版本的大致顺序列出;您也可以查看图表中的延迟时间。测试应用会使用 Android 原生音频 API(基于 OpenSL ES)。
型号 |
平台 版本 |
build 号 |
采样率 (Hz) |
缓冲区空间 (帧) |
缓冲区空间 (ms) |
往返 延迟时间 (ms) ± 一个缓冲区 |
Nexus One |
2.3.6 |
GRK39F |
44100 |
768 |
17.4 |
345 |
Nexus S |
2.3.6 |
GRK39F |
44100 |
1024 |
23.2 |
260 |
Nexus S |
4.0.4 |
IMM76D |
44100 |
1024 |
23.2 |
260 |
Nexus S |
4.1.2 |
JZO54K |
44100 |
880 |
20 |
210 |
Galaxy Nexus |
4.0.1 |
ITL41D |
44100 |
976 |
22.1 |
270 |
Galaxy Nexus |
4.3 |
JWR66Y |
44100 |
144 |
3.3 |
130 |
Nexus 4 |
4.2.2 |
JDQ39E |
48000 |
240 |
5 |
195 |
Nexus 4 |
5.1 |
LMY47O |
48000 |
240 |
5 |
58 |
Nexus 10 |
5.0.2 |
LRX22G |
44100 |
256 |
5.8 |
36 |
Nexus 10 |
5.1 |
LMY47D |
44100 |
256 |
5.8 |
35 |
Nexus 7 2013 |
4.3 |
JSR78D |
48000 |
240 |
5 |
149 |
Nexus 7 2013 |
4.4 |
KRT16S |
48000 |
240 |
5 |
85 |
Nexus 7 2013 |
5.0.2 |
LRX22G |
48000 |
240 |
5 |
64 |
Nexus 7 2013 |
5.1 |
LMY47O |
48000 |
240 |
5 |
55 |
Nexus 7 2013 |
6.0 |
MRA58K |
48000 |
240 |
5 |
55 |
Nexus 5 |
4.4.4 |
KTU84P |
48000 |
240 |
5 |
95 |
Nexus 5 |
5.0.0 |
LRX21O |
48000 |
240 |
5 |
47 |
Nexus 5 |
5.1 |
LMY47I |
48000 |
240 |
5 |
42 |
Nexus 5 |
6.0 |
MRA58K |
48000 |
192 |
4 |
38 |
Nexus 9 |
5.0.0 |
LRX21L |
48000 |
256 |
5.3 |
35 |
Nexus 9 |
5.0.1 |
LRX22C |
48000 |
256 |
5.3 |
38 |
Nexus 9 |
5.1.1 |
LMY47X |
48000 |
256 |
5.3 |
32 |
Nexus 9 |
6.0 |
MRA58K |
48000 |
128 |
2.6 |
15 |
Nexus 6 |
5.0.1 |
LRX22C |
48000 |
240 |
5 |
65 |
Nexus 6 |
5.1 |
LMY47I |
48000 |
240 |
5 |
42 |
Nexus 6 |
6.0 |
MRA58K |
48000 |
192 |
4 |
33 |
Nexus 5X |
6.0 |
MDA89E |
48000 |
192 |
4 |
18 |
Nexus 5X |
8.0.0 |
OPR4.170623.020 |
48000 |
192 |
4 |
18 |
Nexus 5X |
8.1.0 |
OPM2.171019.029.C1 |
48000 |
192 |
4 |
18 |
Nexus 6P |
6.0 |
MDA89D |
48000 |
192 |
4 |
18 |
Nexus 6P |
8.0.0 |
OPR5.170623.014 |
48000 |
192 |
4 |
18 |
Nexus 6P |
8.1.0 |
OPM5.171019.019 |
48000 |
192 |
4 |
18 |
Pixel |
7.1.2 |
NHG47L |
48000 |
192 |
4 |
18 |
Pixel |
8.0.0 |
OPR3.170623.013 |
48000 |
192 |
4 |
18 |
Pixel |
8.1.0 |
OPM1.171019.021 |
48000 |
192 |
4 |
18 |
Pixel XL |
7.1.2 |
NHG47L |
48000 |
192 |
4 |
18 |
Pixel XL |
8.0.0 |
OPR3.170623.013 |
48000 |
192 |
4 |
18 |
图 3. 往返延迟时间
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-26。
[[["易于理解","easyToUnderstand","thumb-up"],["解决了我的问题","solvedMyProblem","thumb-up"],["其他","otherUp","thumb-up"]],[["没有我需要的信息","missingTheInformationINeed","thumb-down"],["太复杂/步骤太多","tooComplicatedTooManySteps","thumb-down"],["内容需要更新","outOfDate","thumb-down"],["翻译问题","translationIssue","thumb-down"],["示例/代码问题","samplesCodeIssue","thumb-down"],["其他","otherDown","thumb-down"]],["最后更新时间 (UTC):2025-03-26。"],[],[],null,["# Audio latency measurements\n\n[Latency](http://en.wikipedia.org/wiki/Latency_%28engineering%29)\nis an important system performance metric. While many kinds of\n[audio latency](/docs/core/audio/latency/latency) metrics exist, one useful and\nwell-understood metric is\n[round-trip latency](/docs/core/audio/latency/measure#measuringRoundTrip),\ndefined as the time it takes for an audio signal to enter the input of a mobile\ndevice, be processed by an app running on the application processor, and exit\nthe output.\n\n**Figure 1.** Round-trip audio latency on\ndevice: T~output~ - T~input~\n\nThis page provides round-trip audio latency measurements for select\nNexus/Pixel devices and Android platform versions.\n\nWhy we measure latency\n----------------------\n\nGoogle measures and reports latency so Android application developers have\nthe data they need to make informed decisions about available latency on actual\ndevices. By sharing latency numbers for select Nexus and Pixel devices, we hope\nto encourage the entire Android community to measure, publish, and reduce\nlatency on *all* Android devices. Please join us in our commitment to\nreducing audio latency!\n\nApp impact on latency\n---------------------\n\nSignal processing can add the following types of delay to latency:\n\n- **Algorithmic** . This delay is inherent and does not vary with the CPU. An example is the delay added by a [finite impulse\n response](http://en.wikipedia.org/wiki/Finite_impulse_response) (FIR) filter.\n- **Computational**. This delay is related to the number of required CPU cycles. For example, attenuation of a signal is usually done by a multiplication operation that takes a varying number of cycles depending on the CPU.\n\nHow we measure\n--------------\n\nWe made the measurements listed on this page using the\n[Dr. Rick O'Rang audio loopback dongle](/docs/core/audio/latency/loopback) and an\n[audio feedback (Larsen effect)\ntest](/docs/core/audio/latency/measure#larsenTest). Measurements assume the application signal processing adds zero\nalgorithmic delay and near-zero computational delay.\n\nWe measure round-trip latency via the headset connector for several reasons:\n\n**Figure 2.** Round-trip latency via headset\nconnector: T~output~ - T~input~\n\n- Important music applications (such as guitar and voice processing) use the headset connector.\n- Measuring round-trip latency of the on-device microphone and speaker can be cumbersome, as it is difficult to keep a feedback loop in open air from entering uncontrolled oscillation.\n- On-device transducers are small and sacrifice frequency response to achieve their small size. To compensate, digital signal processing is applied but increases algorithmic delay for the on-device path.\n\nThere are cases where on-device microphone and speaker latencies *do*\nmatter, but they are usually for one direction, not round-trip. Techniques for\nmeasuring unidirectional latency are described at\n[Measuring Output Latency](/docs/core/audio/latency/measure#measuringOutput)\nand\n[Measuring Input Latency](/docs/core/audio/latency/measure#measuringInput).\n\nExample measurements\n--------------------\n\nThe measurements listed below are specific to a\n[build number](/docs/setup/build-numbers). Devices are listed in\napproximate order of initial release and by platform version; you can also\n[view latencies in a chart](#chart). The test application uses the\nAndroid native audio API based on OpenSL ES.\n\n| Model | Platform version | Build number | Sample rate (Hz) | Buffer size (frames) | Buffer size (ms) | Round-trip latency (ms) ± one buffer |\n|--------------|------------------|--------------------|------------------|----------------------|------------------|--------------------------------------|\n| Nexus One | 2.3.6 | GRK39F | 44100 | 768 | 17.4 | 345 |\n| Nexus S | 2.3.6 | GRK39F | 44100 | 1024 | 23.2 | 260 |\n| Nexus S | 4.0.4 | IMM76D | 44100 | 1024 | 23.2 | 260 |\n| Nexus S | 4.1.2 | JZO54K | 44100 | 880 | 20 | 210 |\n| Galaxy Nexus | 4.0.1 | ITL41D | 44100 | 976 | 22.1 | 270 |\n| Galaxy Nexus | 4.3 | JWR66Y | 44100 | 144 | 3.3 | 130 |\n| Nexus 4 | 4.2.2 | JDQ39E | 48000 | 240 | 5 | 195 |\n| Nexus 4 | 5.1 | LMY47O | 48000 | 240 | 5 | 58 |\n| Nexus 10 | 5.0.2 | LRX22G | 44100 | 256 | 5.8 | 36 |\n| Nexus 10 | 5.1 | LMY47D | 44100 | 256 | 5.8 | 35 |\n| Nexus 7 2013 | 4.3 | JSR78D | 48000 | 240 | 5 | 149 |\n| Nexus 7 2013 | 4.4 | KRT16S | 48000 | 240 | 5 | 85 |\n| Nexus 7 2013 | 5.0.2 | LRX22G | 48000 | 240 | 5 | 64 |\n| Nexus 7 2013 | 5.1 | LMY47O | 48000 | 240 | 5 | 55 |\n| Nexus 7 2013 | 6.0 | MRA58K | 48000 | 240 | 5 | 55 |\n| Nexus 5 | 4.4.4 | KTU84P | 48000 | 240 | 5 | 95 |\n| Nexus 5 | 5.0.0 | LRX21O | 48000 | 240 | 5 | 47 |\n| Nexus 5 | 5.1 | LMY47I | 48000 | 240 | 5 | 42 |\n| Nexus 5 | 6.0 | MRA58K | 48000 | 192 | 4 | 38 |\n| Nexus 9 | 5.0.0 | LRX21L | 48000 | 256 | 5.3 | 35 |\n| Nexus 9 | 5.0.1 | LRX22C | 48000 | 256 | 5.3 | 38 |\n| Nexus 9 | 5.1.1 | LMY47X | 48000 | 256 | 5.3 | 32 |\n| Nexus 9 | 6.0 | MRA58K | 48000 | 128 | 2.6 | 15 |\n| Nexus 6 | 5.0.1 | LRX22C | 48000 | 240 | 5 | 65 |\n| Nexus 6 | 5.1 | LMY47I | 48000 | 240 | 5 | 42 |\n| Nexus 6 | 6.0 | MRA58K | 48000 | 192 | 4 | 33 |\n| Nexus 5X | 6.0 | MDA89E | 48000 | 192 | 4 | 18 |\n| Nexus 5X | 8.0.0 | OPR4.170623.020 | 48000 | 192 | 4 | 18 |\n| Nexus 5X | 8.1.0 | OPM2.171019.029.C1 | 48000 | 192 | 4 | 18 |\n| Nexus 6P | 6.0 | MDA89D | 48000 | 192 | 4 | 18 |\n| Nexus 6P | 8.0.0 | OPR5.170623.014 | 48000 | 192 | 4 | 18 |\n| Nexus 6P | 8.1.0 | OPM5.171019.019 | 48000 | 192 | 4 | 18 |\n| Pixel | 7.1.2 | NHG47L | 48000 | 192 | 4 | 18 |\n| Pixel | 8.0.0 | OPR3.170623.013 | 48000 | 192 | 4 | 18 |\n| Pixel | 8.1.0 | OPM1.171019.021 | 48000 | 192 | 4 | 18 |\n| Pixel XL | 7.1.2 | NHG47L | 48000 | 192 | 4 | 18 |\n| Pixel XL | 8.0.0 | OPR3.170623.013 | 48000 | 192 | 4 | 18 |\n\n**Figure 3.** Round trip latencies"]]