音效劑量

Android 14 支援 並持續監控聲音量測值,藉此建構音訊架構和音訊 HAL 並向使用者發出警告,提醒他們損害暴露程度。

聲量是用來測量特定時間範圍內的聲壓程度。 藉由監控聲量,我們得以保護使用者 音訊暴露量過多或時間過長,因此聽覺防護效果更好 在可攜式 Android 裝置上使用耳機,以盡可能降低 以及聽障

安全聆聽裝置的新標準符合法規 IEC62368-1 第 3 版的聽覺防護規定 (需要登入) 和 EN50332-3 引進聲音的概念

錄音工具可讓原始設備製造商 (OEM) 遵循新的聽覺安全法規。目的地: 支援聲音劑,原始設備製造商 (OEM) 必須遵守介面規格和法規 進行所有自訂和認證作業自訂原始設備製造商 (OEM) 導入 可以略過或修改 Android 開放原始碼計畫的預設音效實作方式。不過 我們強烈建議您使用 Android 開放原始碼計畫

計算聲量

IEC62368-1 第三版和 EN50332-3 標準 計算聲音暴露量 (CSD)。CSD 為 計算方法是整合長期下來的暫時曝光等級 (MEL)。7 天 持續累積 CSD 值 要計算聲量運算

根據 IEC62368-1 3 第 10.6.3.2 節 若 CSD 值達到 100% 限制,系統 音量大小調到 100% 時提醒使用者。如果使用者 如果未確認這則警告,音量就會調低至預先定義的輻射值 能源來源類別 1 (RS1) 的值為 IEC62368-1 表 39。

如 IEC62368-1 第 3 版第 10.6.3.3 節所述,與 注意,每次啟動 MEL 值超過表 39 表 39 的輻射能源來源類別 2 (RS2) 值 IEC62368-1。

符合這些法規的認證,並增加 CSD 價值 因此必須使用使用者感知的準確輸出值 (例如媒體播放輸出)。CSD 運算作業相當重要 使用接近使用者實際聲壓等級的值 暴露在風險中。

建築

視拍攝位置、硬體特性和效果而定 轉場器的 30% 會影響轉譯影格的功率。希望 準確的輸出壓力水平測量,我們擴充了 HAL,以 基礎硬體的 MEL 值,並盡可能考量 數位訊號處理器 (DSP) 或喇叭套用的特效 例如阻抗、敏感度和頻率回應

如果 HAL 無法提供 MEL 值做為備用機制, 分析及計算 CSD音訊架構中的這項運算 是根據 HAL 回報的轉譯輸出內容 傳送到音訊 DSP

音效劑量會導入 SoundDoseHelper 和 如圖 1 所示的 SoundDoseManager,

音符

圖 1. 聲音劑量功能的建築材料;

聲控器

systemserver 程序中的 SoundDoseHelper 類別是 主要收集點。AudioService 類別會管理 SoundDoseHelper 類別。

SoundDoseHelper 類別負責下列項目:

  • 處理新劑量資訊
  • 保留聲音劑量值
  • audioserver 當機時復原狀態
  • 觸發系統 UI 通知
  • 正在調低音量

SoundDoseManager

SoundDoseManager 類別,位於 audioserver 程序中, AudioFlinger 中的一部分 類別,從 HAL 收集聲量資料或在內部進行運算, 以及從傳送至 HAL 的畫面SoundDoseManager 類別會傳送 聲音才會輸出至 SoundDoseHelper 類別

MelProcessor 和 MelAggregator

如果 HAL 無法提供 MEL 值,MelProcessorMelAggregator libaudioutils 中的公用程式 會用於計算內心的聲音

MelProcessor 類別中,主要運算是在具有以下內容的緩衝區上執行 呼叫 MelProcessor::process(const void* buffer, size_t bytes) 來取得音訊樣本 如有需要,原始設備製造商 (OEM) 可以在 HAL 實作中使用 MelProcessor

MelAggregator 類別會從不同的音訊通訊埠接收 MEL 值, 以七天的滾動期間計算 CSD 值。MelAggregator::aggregateAndAddNewMelRecord_l(MelRecord mel) 方法 會執行邏輯。結果會傳送到以下項目的 SoundDoseManager 類別: 與 AudioService 的通訊。

實作

自 Android 14 起,HIDL 介面擴充功能已淘汰。 因此新的 HAL 介面可用來擷取計算出的 MEL 值,並發布 名為 ISoundDose 的警告 是 AIDL 音訊 HAL 的一部分。不過 實作 AIDL 音訊 HAL 的實作者如果需要更多時間來整合 AIDL 音訊 HAL, 獨立聲音劑量 AIDL HAL ISoundDoseFactory 介面。這將是 日後已淘汰的功能

HAL 支援聲音的 HAL 方式如以下程式碼所示 範例:

/**
 * This interface provides functions related to sound exposure control required for compliance to
 * EN/IEC 62368-1 3rd edition. Implementing this interface is mandatory for devices for which
 * compliance to this standard is mandated and implementing audio offload decoding or other direct
 * playback paths where volume control happens below the audio HAL.
 */
@VintfStability
interface ISoundDose {
    /**
     * Max value in dBA used for momentary exposure warnings as defined by IEC62368-1
     * 3rd edition. This value represents the default RS2 upper bound.
     */
    const int DEFAULT_MAX_RS2 = 100;
    /** Min value of the RS2 threshold in dBA as defined by IEC62368-1 3rd edition. */
    const int MIN_RS2 = 80;

    /**
     * Sets the RS2 upper bound used for momentary exposure warnings. Default value is
     * DEFAULT_MAX_RS2 as specified in IEC62368-1 3rd edition.
     *
     * @param rs2ValueDbA custom RS2 upper bound to use
     * @throws EX_ILLEGAL_ARGUMENT if rs2ValueDbA is greater than DEFAULT_MAX_RS2 or lower
     *                             than MIN_RS2
     */
    void setOutputRs2UpperBound(float rs2ValueDbA);

    /**
     * Gets the RS2 upper bound used for momentary exposure warnings.
     *
     * @return the RS2 upper bound in dBA
     */
    float getOutputRs2UpperBound();

    /**
     * Registers the HAL callback for sound dose computation. If sound dose is supported
     * the MEL values and exposure notifications will be received through this callback
     * only. The internal framework MEL computation will be disabled.
     * It is not possible to unregister the callback. The HAL is responsible to provide
     * the MEL values throughout its lifecycle.
     *
     * @param callback to use when new updates are available for sound dose
     */
    void registerSoundDoseCallback(in IHalSoundDoseCallback callback);

    @VintfStability
    oneway interface IHalSoundDoseCallback {
        /**
         * Called whenever the current MEL value exceeds the set RS2 upper bound.
         *
         * @param currentDbA the current MEL value which exceeds the RS2 upper bound
         * @param audioDevice the audio device where the MEL exposure warning was recorded
         */
        void onMomentaryExposureWarning(float currentDbA, in AudioDevice audioDevice);

        @VintfStability
        parcelable MelRecord {
            /**
             * Array of continuously recorded MEL values >= MIN_RS2 (1 per second).
             * First value in the array was recorded at 'timestamp'.
             */
            float[] melValues;
            /**
             * Corresponds to the time in seconds, as reported by CLOCK_MONOTONIC, when
             * the first MEL entry in melValues was recorded. The timestamp values have
             * to be consistent throughout all audio ports, equal timestamp values will
             * be aggregated.
             */
            long timestamp;
        }

        /**
         * Provides a MelRecord containing continuous MEL values sorted by timestamp.
         * Note that all the MEL values originate from the audio device specified by audioDevice.
         * In case values from multiple devices need to be reported, the caller should execute
         * this callback once for every device.
         *
         * @param melRecord contains the MEL values used for CSD
         * @param audioDevice the audio device where the MEL values were recorded
         */
        void onNewMelValues(in MelRecord melRecord, in AudioDevice audioDevice);
    }
}

新的 HAL 介面實作回呼 旨在向架構提供短暫曝光資訊,並提供 MEL 價值 當輸出等級超過 RS1 時。實作這些介面後 就是用來製作 CSD 報表如未實作這個回呼, AudioFlinger 上的備用廣告導入作業 是用來計算 CSD 值的估計值。

Soundsse 獨立 AIDL 支援

除非原始設備製造商 (OEM) 能夠整合 AIDL 音訊 HAL 中的聲音,否則他們可以使用 獨立的 AIDL API ISoundDoseFactoryISoundDoseFactory 使用 ISoundDose 介面,如 請看以下程式碼範例:

@VintfStability
interface ISoundDoseFactory {
    /**
     * Retrieve the sound dose interface for a given audio HAL module name.
     *
     * If a device must comply to IEC62368-1 3rd edition audio safety requirements and is
     * implementing audio offload decoding or other direct playback paths where volume control
     * happens below the audio HAL, it must return an instance of the ISoundDose interface.
     * The same instance must be returned during the lifetime of the HAL module.
     * If the HAL module does not support sound dose, null must be returned, without throwing
     * any errors.
     *
     * @param module for which we trigger sound dose updates.
     * @return An instance of the ISoundDose interface implementation.
     * @throws EX_ILLEGAL_STATE If there was an error creating an instance.
     */
    @nullable ISoundDose getSoundDose(in @utf8InCpp String module);
}

Sound dose AIDL 音訊 HAL 支援

聲控器介面為 AIDL 音訊 HAL 的一部分, 擴充 IModule 介面,如以下程式碼範例所示:

@VintfStability
interface IModule {
…
    /**
     * Retrieve the sound dose interface.
     *
     * If a device must comply to IEC62368-1 3rd edition audio safety requirements and is
     * implementing audio offload decoding or other direct playback paths where volume control
     * happens below the audio HAL, it must return an instance of the ISoundDose interface.
     * The same instance must be returned during the lifetime of the HAL module.
     * If the HAL module does not support sound dose, null must be returned, without throwing
     * any errors.
     *
     * @return An instance of the ISoundDose interface implementation.
     * @throws EX_ILLEGAL_STATE If there was an error creating an instance.
     */
    @nullable ISoundDose getSoundDose();
}

這項功能會實作 IEC62368-1 中所述的新法規 第 3 版和 EN50332-3,因此沒有面向外部的 API。

原始設備製造商 (OEM) 可以在自家裝置中實作新的 HAL 介面和 為音訊架構提供準確的 MEL 資料 (建議做法),或者 並提供自訂的聲音劑量

啟用聲音劑量的計算功能

根據預設,Android 開放原始碼計畫支援可確保認證的聽覺安全邏輯 符合現行的 EN50332-2 和 IEC62368-1 10.6.5 標準

Android 14 已停用聲音計算功能 報表。

請根據以下準則計算聲音數 就從 Android 14-QPR1 開始

  • 如果您所在的國家/地區實施了聲音劑量法規,請確認 config.xml中的config_safe_media_volume_enabled 已設為 true

  • 如要符合 EN50332-3 和 IEC62368-1 10.6.3 規定,供應商必須 這個標記中的 config_safe_sound_dosage_enabled 旗標 config.xmltrue。若裝置支援卸載解碼,且並未實作 sound dose HAL 介面 config_safe_sound_dosage_enabled不得設為 true。此時 將 config_safe_sound_dosage_enabled 設為 true 可能會導致 CSD 不正確 和安全聽力標準的認證問題。

以下決策圖說明評估 國家/地區限制和旗幟值 (CSD 或舊版) 聽覺安全等級 (在 Android 14 之前導入) 計算方式

enable_csd

圖 2. 啟用聲音數的計算功能 (系統將添加邏輯 Android 14-QPR1)。

驗證

實作 HAL 介面時,原始設備製造商 (OEM) 必須根據 VtsHalAudioCoreTargetTest 定義的 VTS 測試案例 實作 IModule AIDL 音訊 HAL 實作,或由 VtsHalSoundDoseFactoryTargetTest 提供 以便單獨運用 Dose AIDL HAL 實作