自 2025 年 3 月 27 日起,我们建议您使用 android-latest-release
而非 aosp-main
构建 AOSP 并为其做出贡献。如需了解详情,请参阅 AOSP 的变更。
高解析度音频
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
Android 10 版本包括以下针对高解析度音频的改进:
- 浮动:更新了 WAV、FLAC 编解码器和提取器,以支持浮动格式(24+ 位无损精度)。缩混和虚拟环绕音效已更新为浮动格式。MediaPlayer (NuPlayer) 支持使用更新后的精度。
- 高频:更新了 WAV、FLAC 编解码器和提取器,以支持 192kHz。Android 提供的默认音效已在标准频率下进行了测试,确认其支持 192kHz。允许的标准频率为 88.2kHz、96kHz、176.4kHz 和 192kHz。
- 多通道:默认的 Android 播放音效已进行了测试,确认其支持多通道(多达 8 通道)。
- 时序:时序信息包含在整个音频框架中。
从 Android 9 开始,以下方面的改进不需要任何合作伙伴实现:
- 客户端的同时输出音轨数量从 14 增加到 40,因为对 Android 8.x 中的应用而言,有限的客户端
AudioTrack
实例已经成为一个需要解决的问题。
- 客户端/服务器的最大内存从 4MB 增加到 32MB(具体取决于设备总内存),以允许同时存在更多高解析度音轨。
- 混合音轨总数从 32 增加到 256,以防止应用和系统界面之间出现资源争用情况。
输出音效方面的变更
如需了解 Android 11 版本的变更,请参阅音频效果。
在 Android 9 版本之前,音效链处理是以立体声 int16 样本格式实现的。这种方法存在以下几项限制:
- 所有输出音效都强制从浮点音频数据转换为 int16,而这会导致精确度失真。
- 输出音效遭到通道数大于 2 的输出接收器的拒绝。
在 Android 9 版本中,音效链处理通道进行了升级,以支持多通道浮动格式。要点:
- Android 软件音效已经改用立体声浮动格式。
- 格式适配器支持旧版音效,可根据需要将浮动格式转换为 int16。
实现输出音效
frameworks/av/media/libeffects
下提供了输出音效的参考实现。
实现自己的自定义输出音效的合作伙伴应针对 Android 10 版本执行以下操作:
- 更新输出音效以支持多通道浮动格式:
- 不再需要 Int16 处理支持。
- 支持的输出通道数为 2-8 个(出于未来兼容性方面的考虑,通道数可以为 1-30 个)。
- 对于插入音效,支持与输出通道数一致的输入通道数。对于辅助音效,输入通道数仍为 1(单声道)。
- 支持通道位置掩码(规范)和
(1 << n) - 1
的通道索引掩码。
- 如果您必须继续支持旧版供应商输出音效且无法更新它们,请按如下方式验证旧代码:
- 旧版输出(插入)音效必须拒绝
EFFECT_CMD_SET_CONFIG
中不受支持的配置。
- 检查格式是否为 int16。
- 检查输入和输出通道掩码是否为立体声。
- 如果任一检查失败,将返回
-EINVAL
。
- 旧版输出(辅助)音效由 AudioFlinger 配置,具有单声道输入通道掩码,并可能具有多通道输出通道掩码(具体取决于输出接收器是否为多通道)。它们必须拒绝
EFFECT_CMD_SET_CONFIG
中不受支持的配置。
- 检查格式是否为 int16。
- 检查输入通道掩码是否为单声道,输出通道掩码是否为立体声。
- 如果任一检查失败,将返回
-EINVAL
。
- 验证旧代码。不要假设它有效!
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-03-26。
[null,null,["最后更新时间 (UTC):2025-03-26。"],[],[],null,["# High-resolution audio\n\nThe Android 10 release includes the following\nimprovements for high-resolution audio:\n\n- **Float:** WAV, FLAC codecs, and extractors are updated to support float (24+ bits of lossless precision). Downmix and Virtualizer effects are updated to float. Updated precision is allowed by MediaPlayer (NuPlayer).\n- **High-frequency:** WAV, FLAC codecs, and extractors are updated to support 192 kHz. The default Android supplied effects are tested for 192 kHz support at standard frequencies. The standard frequencies permitted are 88.2 kHz, 96 kHz, 176.4 kHz, and 192 kHz.\n- **Multichannel:** Default Android playback effects are tested for multichannel support to eight channels.\n- **Timing:** Timing information is included throughout the audio framework.\n\nStarting in Android 9, the following improvements\ndon't require any partner implementation:\n\n- The number of simultaneous client output tracks increases from 14 to 40, as limited client instances of `AudioTrack` have been an issue for apps in Android 8.x.\n- Maximum client/server memory increases from 4 MB to 32 MB (depending on total device memory) to allow more simultaneous high-resolution audio tracks.\n- Total mixed tracks increases from 32 to 256 to prevent resource contention between apps and the System UI.\n\nOutput effect changes\n---------------------\n\nSee [Audio\neffects](/docs/core/audio/audio-effects) for Android 11 release changes.\n\nPrior to the Android 9 release, effect chain processing\nwas implemented in stereo int16 sample format. This had several limitations:\n\n- All output effects forced conversion from floating point audio data to int16, causing loss of precision.\n- Output effects were rejected from output sinks with a channel count greater than two.\n\nIn the Android 9 release, the effect chain processing\npipeline is upgraded to support the multichannel float format. Key points:\n\n- Android software effects are already migrated to stereo float.\n- Legacy effects are supported with format adapters, which convert float to int16 as needed.\n\nImplement output effects\n------------------------\n\nA reference implementation for output effects is available under\n`frameworks/av/media/libeffects`.\n\nPartners implementing their own custom output effects should do the\nfollowing for the Android 10 release:\n\n- Update output effects to support the multichannel float format:\n - Int16 processing support is no longer required.\n - Support output channel counts from 2--8 (for future compatibility consider counts from 1--30).\n - Support input channel counts matching output channel counts for insert effects. Auxiliary effects continue to see an input channel count of 1 (mono).\n - Support both channel position masks (canonical) and channel index masks of `(1 \u003c\u003c n) - 1`.\n- If you must continue to support legacy vendor output effects and can't update them, then verify legacy code as follows:\n - Legacy output (insert) effects **must reject** unsupported configurations in `EFFECT_CMD_SET_CONFIG`.\n - Check that the format is int16.\n - Check that the input and output channel masks are stereo.\n - If either check fails, return `-EINVAL`.\n - Legacy output (auxiliary) effects are configured by AudioFlinger with a mono input channel mask and potentially multichannel output channel masks, depending on whether the output sink is multichannel. They **must reject** unsupported configurations in `\n EFFECT_CMD_SET_CONFIG`.\n - Check that the format is int16.\n - Check that the input channel mask is mono and the output channel mask is stereo.\n - If either check fails, return `-EINVAL`.\n - Verify legacy code. Don't assume that it works!"]]