aduio_policy_configuration.xml内容分为三大模块:
- 全局配置;
- modules模块;
- volume section;
1. globalConfiguration
<globalConfiguration speaker_drc_enabled="true"/>
speaker_drc_enabled值为ture时:在DEVICE_CATEGORY_SPEAKER路径上使用DRC增强柔和声音的设备,用于相应地调整音量曲线。
2. modules模块
modules下面包含module列表,每个音频硬件模块都对应一个module。模块包括:primary、A2DP、USB、remote_submix、hearing_aid。
这里以primary为例:
每个module都将包含两个用于音频HAL的必需标记:“ halVersion”和“ name”。
<module name="primary" halVersion="3.0">
attachedDevices: 永久连接的设备,也就是内置的设备
<attachedDevices>
<item>Speaker</item> <!-- 扬声器 -->
<item>Built-In Mic</item> <!-- 内置麦克 -->
<item>Built-In Back Mic</item><!-- 内置后侧麦克 -->
</attachedDevices>
defaultOutputDevice:默认的输出设备(不适用任何规则时默认设备)
devicePorts:可以通过此模块访问的所有输入和输出设备的设备描述符的列表。包含内置设备和外接设备。
<devicePorts>
<!-- Output devices declaration, i.e. Sink DEVICE PORT -->
//听筒配置
<devicePort tagName="Earpiece" type="AUDIO_DEVICE_OUT_EARPIECE" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="48000" channelMasks="AUDIO_CHANNEL_IN_MONO"/>
</devicePort>
//扬声器配置
<devicePort tagName="Speaker" role="sink" type="AUDIO_DEVICE_OUT_SPEAKER" address="">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
<gains>
<gain name="gain_1" mode="AUDIO_GAIN_MODE_JOINT"
minValueMB="-8400"
maxValueMB="4000"
defaultValueMB="0"
stepValueMB="100"/>
</gains>
</devicePort>
//有线耳机
<devicePort tagName="Wired Headset" type="AUDIO_DEVICE_OUT_WIRED_HEADSET" role="sink">
<profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
samplingRates="48000" channelMasks=<