Detailed explanation of audio_policy_configuration.xml configuration file

<modules> in audio_policy_configuration.xml corresponds to the so of each audio hal, and the mixPorts, devicePorts and routes listed in the module fully describe the audio routing rules after parsing.

    module name : Supports "primary" (for car usage scenarios), "A2DP", "remote_submix" and "USB". The module name and corresponding audio driver should be compiled into audio.primary.$(variant).so.


    devicePorts : Contains a list of device descriptors for all input and output devices (both permanently attached and removable) accessible from this module. There are actual physical devices, and there are defined device types in android, such as AUDIO_DEVICE_OUT_SPEAKER, AUDIO_DEVICE_IN_HDMI, AUDIO_DEVICE_OUT_BLUETOOTH_A2DP, etc.


    mixPorts : Contains a list of all output streams and input streams provided by the audio HAL, a logical audio stream. Each mixPort instance can be thought of as a physical audio stream delivered to the Android AudioService.


   routes : A list defining possible connections between input and output devices or between audio streams and devices.

The difference between mixPorts and devicePorts

devicePort

mixPort is a logical audio stream. In xml, we can customize the name of the logical audio stream. Generally, the default primary_out stream

        <mixPort name="primary_out" role="source" flags="AUDIO_OUTPUT_FLAG_PRIMARY">
                        <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
                                 samplingRates="48000" channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
                    </mixPort>

Subordinate to the primary module, the primary out flow is used as the source of a route, and this goal is also achieved through the primary hal. The description of this route is as follows

    .......
    <devicePort tagName="Speaker" role="sink" type="AUDIO_DEVICE_OUT_SPEAKER">
                        <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
                                 samplingRates="48000"
                                 channelMasks="AUDIO_CHANNEL_OUT_STEREO"/>
    ......
    ......
     
     <route type="mix" sink="Speaker"
                           sources="primary_out"/>
    ......
    ......

The audio stream "primary_out" whose flag is AUDIO_OUTPUT_FLAG_PRIMARY will flow to the sink device Speaker whose device is AUDIO_DEVICE_OUT_SPEAKER through the primary hal

 

Guess you like

Origin blog.csdn.net/wangbuji/article/details/126137623