自 2025 年 3 月 27 日起,我們建議您使用 android-latest-release
而非 aosp-main
建構及貢獻 AOSP。詳情請參閱「Android 開放原始碼計畫變更」。
高解析度音訊
透過集合功能整理內容
你可以依據偏好儲存及分類內容。
Android 10 版本包含下列高解析度音訊改善項目:
- 浮點:WAV、FLAC 編解碼器和擷取器已更新,以支援浮點 (24 位元以上無損精確度)。將 Downmix 和 Virtualizer 特效更新為浮點。MediaPlayer (NuPlayer) 允許更新精確度。
- 高頻率:WAV、FLAC 轉碼器和擷取器已更新,可支援 192 kHz。在標準頻率下,已測試預設的 Android 提供效果是否支援 192 kHz。允許的標準頻率為 88.2 kHz、96 kHz、176.4 kHz 和 192 kHz。
- 多聲道:我們測試了預設的 Android 播放效果,以便支援多聲道至八聲道。
- 時間:整個音訊架構都包含時間資訊。
自 Android 9 起,以下改善項目不需要任何合作夥伴導入:
- 由於
AudioTrack
的用戶端例項有限,在 Android 8.x 中的應用程式中會造成問題,因此同時用戶端輸出音軌的數量從 14 個增加到 40 個。
- 用戶端/伺服器記憶體上限從 4 MB 提高至 32 MB (取決於裝置總記憶體),以便同時播放更多高解析度音訊軌。
- 混合軌跡總數從 32 增加至 256,以避免應用程式和系統 UI 之間發生資源爭用情形。
輸出效果變更
如要瞭解 Android 11 版本的異動內容,請參閱「音效」。
在 Android 9 發布之前,特效鏈條處理作業是以立體聲 int16 取樣格式實作。這有幾項限制:
- 所有輸出效果都會強制將浮點音訊資料轉換為 int16,導致精確度降低。
- 輸出效果已從輸出匯出端拒絕,因為其管道數量超過兩個。
在 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 和/或其關係企業的商標或註冊商標。
上次更新時間:2025-07-27 (世界標準時間)。
[[["容易理解","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"]],["上次更新時間:2025-07-27 (世界標準時間)。"],[],[],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!"]]