【Android Audio】dumpsys media.audio_policy分析【不定期更新文章】

dumpsys media.audio_policy

  • 1、mEngine->getPhoneState()
  • 2、所有强制设备输出的状态显示(Engine::setForceUse函数所设置)
  • 3、(mTtsOutputAvailable/mMasterMono/mConfig.getSource())
  • 4、所有可用输出设备(mAvailableOutputDevices)【DeviceVector】
    • 4.1、mId
    • 4.2、mTagName
    • 4.3、mDeviceTypeAddr【AudioDeviceTypeAddr】
    • 4.4、mEncapsulationModes、mEncapsulationMetadataTypes
    • 4.5、mGains【AudioGains】、mProfiles【AudioProfileVector】
  • 5、展示当前平台所有可用的输入设备(mAvailableInputDevices)
  • 6、所有的Module(mHwModulesAll)【HwModuleCollection】
    • 6.1、mName, mHandle, mHalVersion
    • 6.2、mOutputProfiles【OutputProfileCollection】
      • 6.2.1、mProfiles【AudioProfileVector】
      • 6.2.2、mFlags、maxOpenCount、curOpenCount、maxActiveCount、curActiveCount
      • 6.2.3、mGains【AudioGains】
      • 6.2.4、mSupportedDevices【DeviceVector】
    • 6.3、mInputProfiles【InputProfileCollection】
    • 6.4、Declared devices (mDeclaredDevices)【DeviceVector】
    • 6.5、Dynamic devices (mDynamicDevices)【DeviceVector】
    • 6.6、mRoutes【AudioRouteVector】
      • 6.6.1、mType【audio_route_type_t 】
      • 6.6.2、mSink【PolicyAudioPort】
      • 6.6.3、mSources【PolicyAudioPortVector 】
  • 7、所有的SwAudioOutputDescriptor (mOutputs)
  • 8、所有的AudioInputDescriptor (mInputs)
  • 9、所有的音效EffectDescriptor (mEffects)
  • 10、所有AudioPatch (mAudioPatches)
  • 11、所有AudioPolicyMix (mPolicyMixes)
  • 12、所有SourceClientDescriptor (mAudioSources.dump)
  • 13、(mAllowedCapturePolicies)
  • 14、Engine (mEngine->dump)

命令:
dumpsys media.audio_policy

AudioPolicyManager: 0xf1e5a000
Command Thread: 0xf1ff3300 
Supported System Usages:
AudioCommandThread 0xf1ff3300 Dump
- Commands:
   Command Time        Wait pParam
  Last Command
   01      014581.648  0    0xf19e5440

AudioPolicyManager Dump: 0xf1e5a000
 Primary Output: 13

1、mEngine->getPhoneState()

 Phone state: AUDIO_MODE_NORMAL

2、所有强制设备输出的状态显示(Engine::setForceUse函数所设置)

 Force use for communications: 0
 Force use for media: 0
 Force use for record: 0
 Force use for dock: 8
 Force use for system: 0
 Force use for HDMI system audio: 12
 Force use for encoded surround output: 0
 Force use for vibrate ringing: 0

Google code地址

【Android Audio】dumpsys media.audio_policy分析【不定期更新文章】_第1张图片

3、(mTtsOutputAvailable/mMasterMono/mConfig.getSource())

TTS output not available
 Master mono: off
 Config source: /vendor/etc/audio_policy_configuration.xml

4、所有可用输出设备(mAvailableOutputDevices)【DeviceVector】

mAvailableOutputDevices为DeviceVector类型,其包含了多个sp实例。

class DeviceDescriptor : public DeviceDescriptorBase,
                         public PolicyAudioPort, public PolicyAudioPortConfig {
...
    std::string mTagName; // Unique human readable identifier for a device port found in conf file.
    FormatVector        mEncodedFormats;
    audio_format_t      mCurrentEncodedFormat;
};
class DeviceDescriptorBase : public AudioPort, public AudioPortConfig {...};
class AudioPort : public virtual RefBase, public virtual Parcelable {
...
    AudioGains mGains; // gain controllers
    std::string  mName;
    audio_port_type_t mType;
    audio_port_role_t mRole;
    AudioProfileVector mProfiles; // AudioProfiles supported by this port (format, Rates, Channels)
};
class PolicyAudioPort : public virtual RefBase, private HandleGenerator<audio_port_handle_t> {
...
    uint32_t mFlags; // attribute flags mask (e.g primary output, direct output...).
    sp<HwModule> mModule;     // audio HW module exposing this I/O stream
    AudioRouteVector mRoutes; // Routes involving this port
};

4.1、mId

  - id:  2

4.2、mTagName

tagName="Speaker"
  - tag name: Speaker

4.3、mDeviceTypeAddr【AudioDeviceTypeAddr】

mDeviceTypeAddr.mType

  - type: AUDIO_DEVICE_OUT_SPEAKER

4.4、mEncapsulationModes、mEncapsulationMetadataTypes

  - supported encapsulation modes: 0  
  - supported encapsulation metadata types: 0

4.5、mGains【AudioGains】、mProfiles【AudioProfileVector】

mGains对应的xml配置为

 <devicePort tagName="Speaker" role="sink" type="AUDIO_DEVICE_OUT_SPEAKER">
     <gains>
         <gain name="gain_1" mode="AUDIO_GAIN_MODE_JOINT"
               minValueMB="-10000"
               maxValueMB="0"
               defaultValueMB="-6000"
               stepValueMB="100"/>
     </gains>
 </devicePort>

mProfiles对应xml配置

AudioPort::dump(dst, spaces, verbose);
- Available output devices:
  Device 1:
  - id:  2
  - tag name: Speaker
  - type: AUDIO_DEVICE_OUT_SPEAKER
  - supported encapsulation modes: 0  - supported encapsulation metadata types: 0  - Profiles:
      Profile 0:[dynamic format][dynamic channels][dynamic rates]
  - gains:
    Gain 1:
    - mode: 00000001
    - channel_mask: 00000000
    - min_value: -10000 mB
    - max_value: 0 mB
    - default_value: -6000 mB
    - step_value: 100 mB
    - min_ramp_ms: 0 ms
    - max_ramp_ms: 0 ms

5、展示当前平台所有可用的输入设备(mAvailableInputDevices)

- Available input devices:
  Device 1:
  - id: 46
  - tag name: USB-Audio - USB Audio Device
  - type: AUDIO_DEVICE_IN_USB_HEADSET
  - supported encapsulation modes: 0  - supported encapsulation metadata types: 0  - address: card=1;device=0;
  - name: USB-Audio - USB Audio Device
  - Profiles:
      Profile 0:[dynamic format]
          - format: AUDIO_FORMAT_PCM_16_BIT
          - sampling rates:44100, 48000
          - channel masks:0x000c, 0x0010, 0x80000001
  Device 2:
  - id: 12
  - tag name: HDMI In
  - type: AUDIO_DEVICE_IN_AUX_DIGITAL|AUDIO_DEVICE_IN_HDMI
  - supported encapsulation modes: 0  - supported encapsulation metadata types: 0  - Profiles:
      Profile 0:[dynamic format][dynamic channels][dynamic rates]
      Profile 1:
          - format: AUDIO_FORMAT_PCM_16_BIT
          - sampling rates:8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000
          - channel masks:0x000c, 0x0010
  - gains:
    Gain 1:
    - mode: 00000001
    - channel_mask: 00000000
    - min_value: -10000 mB
    - max_value: 0 mB
    - default_value: -6000 mB
    - step_value: 100 mB
    - min_ramp_ms: 0 ms
    - max_ramp_ms: 0 ms
  Device 3:
  - id: 17
  - tag name: Built-In Mic
  - type: AUDIO_DEVICE_IN_BUILTIN_MIC
  - supported encapsulation modes: 0  - supported encapsulation metadata types: 0  - address: top
  - Profiles:
      Profile 0:
          - format: AUDIO_FORMAT_PCM_32_BIT
          - sampling rates:8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000
          - channel masks:0x000c, 0x0010, 0x0030
      Profile 1:
          - format: AUDIO_FORMAT_PCM_32_BIT
          - sampling rates:16000
          - channel masks:0x000c, 0x0010

6、所有的Module(mHwModulesAll)【HwModuleCollection】

mHwModulesAll为HwModuleCollection类型,其包含了多个sp实例。
所有xml中配置的module模块 contains all modules declared in the config
/vendor/etc/audio_policy_configuration.xml
a2dp_audio_policy_configuration.xml
usb_audio_policy_configuration.xml
r_submix_audio_policy_configuration.xml
hearing_aid_audio_policy_configuration.xml

【Android Audio】dumpsys media.audio_policy分析【不定期更新文章】_第2张图片【Android Audio】dumpsys media.audio_policy分析【不定期更新文章】_第3张图片

HW Modules dump:

以Module 1 primary为例,其他module相同

class HwModule : public RefBase {
    const String8 mName; // base name of the audio HW module (primary, a2dp ...)
    audio_module_handle_t mHandle;
    OutputProfileCollection mOutputProfiles; // output profiles exposed by this module
    InputProfileCollection mInputProfiles;  // input profiles exposed by this module
    uint32_t mHalVersion; // audio HAL API version
    DeviceVector mDeclaredDevices; // devices declared in audio_policy configuration file.
    DeviceVector mDynamicDevices; /**< devices that can be added/removed at runtime (e.g. rsbumix)*/
    AudioRouteVector mRoutes;
    PolicyAudioPortVector mPorts;
};
void HwModule::dump(String8 *dst) const

6.1、mName, mHandle, mHalVersion

- HW Module 1:
  - name: primary (mName)
  - handle: 10  (mHandle)
  - version: 3.0  (mHalVersion)

6.2、mOutputProfiles【OutputProfileCollection】

mOutputProfiles为OutputProfileCollection类型,其包含了多个sp实例。

  - outputs:

这里以HDMI OUT设备获取profile为例,HDMI OUT当前支持了compress offload,direct output,mmap_no_irq_out_dynamic 3种典型类别的profile。

class IOProfile : public AudioPort, public PolicyAudioPort {
...
    // Maximum number of input or output streams that can be simultaneously opened for this profile.
    // By convention 0 means no limit. To respect legacy behavior, initialized to 1 for output
    // profiles and 0 for input profiles
    uint32_t     maxOpenCount;
    // Number of streams currently opened for this profile.
    uint32_t     curOpenCount;
    // Maximum number of input or output streams that can be simultaneously active for this profile.
    // By convention 0 means no limit. To respect legacy behavior, initialized to 0 for output
    // profiles and 1 for input profiles
    uint32_t     maxActiveCount;
    // Number of streams currently active for this profile. This is not the number of active clients
    // (AudioTrack or AudioRecord) but the number of active HAL streams.
    uint32_t     curActiveCount;
    DeviceVector mSupportedDevices; // supported devices: this input/output can be routed from/to
};
class AudioPort : public virtual RefBase, public virtual Parcelable {
...
    AudioGains mGains; // gain controllers
    std::string  mName;
    audio_port_type_t mType;
    audio_port_role_t mRole;
    AudioProfileVector mProfiles; // AudioProfiles supported by this port (format, Rates, Channels)
};
class PolicyAudioPort : public virtual RefBase, private HandleGenerator<audio_port_handle_t> {
...
    uint32_t mFlags; // attribute flags mask (e.g primary output, direct output...).
    sp<HwModule> mModule;     // audio HW module exposing this I/O stream
    AudioRouteVector mRoutes; // Routes involving this port
};
void IOProfile::dump(String8 *dst) const
{
    std::string portStr;
    AudioPort::dump(&portStr, 4);--------------------------------------------> AudioPort::dump
}
  • 一个IOProfile对应一个output [x]:,同时对应audio_policy_configuration.xml中一个MixPort定义
void AudioPort::dump(std::string *dst, int spaces, bool verbose) const {
    if (!mName.empty()) {
        dst->append(base::StringPrintf("%*s- name: %s\n", spaces, "", mName.c_str()));
    }
    if (verbose) {
        std::string profilesStr;
        mProfiles.dump(&profilesStr, spaces);   --------------------------------------> AudioProfileVector::dump
        dst->append(profilesStr);
        if (mGains.size() != 0) {
            dst->append(base::StringPrintf("%*s- gains:\n", spaces, ""));
            for (size_t i = 0; i < mGains.size(); i++) {
                std::string gainStr;
                mGains[i]->dump(&gainStr, spaces + 2, i);
                dst->append(gainStr);
                ...

6.2.1、mProfiles【AudioProfileVector】

  • 一个IOProfile可能支持多个profile(mProfiles)定义,也就是包含多个AudioProfile实例。每个AudioProfile对应一条Profile x:
void AudioProfileVector::dump(std::string *dst, int spaces) const
{
   dst->append(base::StringPrintf("%*s- Profiles:\n", spaces, ""));
   for (size_t i = 0; i < size(); i++) {
       dst->append(base::StringPrintf("%*sProfile %zu:", spaces + 4, "", i));
       std::string profileStr;
       at(i)->dump(&profileStr, spaces + 8);   ----------------------------------------> AudioProfile::dump
       dst->append(profileStr);
   }
}
void AudioProfile::dump(std::string *dst, int spaces) const
class AudioProfile final : public RefBase, public Parcelable
{
...
    std::string  mName;
    audio_format_t mFormat; // The format for an audio profile should only be set when initialized.
    ChannelMaskSet mChannelMasks;
    SampleRateSet mSamplingRates;
    bool mIsDynamicFormat = false;
    bool mIsDynamicChannels = false;
    bool mIsDynamicRate = false;
};
  • 一个AudioProfile对应一个Profile [x]:.
  1. 如果是audio_policy_configuration.xml定义了MixPort的profile,则对应该文件中的一条profile字段定义;
dumpsys中显示:
output 3:
- name: compress offload
- Profiles:
	Profile 0:
	    - format: AUDIO_FORMAT_AC3
	    - sampling rates:32000, 44100, 48000
	    - channel masks:0x0001, 0x0003, 0x0007, 0x000f, 0x0033, 0x0037, 0x003f, 0x0103, 0x0107
	Profile 1:
		- format: AUDIO_FORMAT_E_AC3
		- sampling rates:16000, 22050, 24000, 32000, 44100, 48000
		- channel masks:0x0001, 0x0003, 0x0007, 0x000f, 0x0033, 0x0037, 0x003f, 0x0103, 0x0107, 0x063f
	Profile 2:
		- format: AUDIO_FORMAT_E_AC3_JOC
		- sampling rates:16000, 22050, 24000, 32000, 44100, 48000
		- channel masks:0x0001, 0x0003, 0x0007, 0x000f, 0x0033, 0x0037, 0x003f, 0x0103, 0x0107, 0x063f
	Profile 3:
...
audio_policy_configuration.xml中静态的定义了MixPort的profile:
<mixPort name="compress offload" role="source" flags="AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD">
	<profile name="ac3 raw" format="AUDIO_FORMAT_AC3"
			 samplingRates="32000,44100,48000"
			 channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_TRI,AUDIO_CHANNEL_OUT_TRI_BACK,AUDIO_CHANNEL_OUT_3POINT1,AUDIO_CHANNEL_OUT_QUAD,AUDIO_CHANNEL_OUT_SURROUND,AUDIO_CHANNEL_OUT_PENTA,AUDIO_CHANNEL_OUT_5POINT1"/>
	<profile name="eac3 raw" format="AUDIO_FORMAT_E_AC3"
			 samplingRates="16000,22050,24000,32000,44100,48000"
			 channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_TRI,AUDIO_CHANNEL_OUT_TRI_BACK,AUDIO_CHANNEL_OUT_3POINT1,AUDIO_CHANNEL_OUT_QUAD,AUDIO_CHANNEL_OUT_SURROUND,AUDIO_CHANNEL_OUT_PENTA,AUDIO_CHANNEL_OUT_5POINT1,AUDIO_CHANNEL_OUT_7POINT1"/>
	<profile name="eac3-joc raw" format="AUDIO_FORMAT_E_AC3_JOC"
			 samplingRates="16000,22050,24000,32000,44100,48000"
			 channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_TRI,AUDIO_CHANNEL_OUT_TRI_BACK,AUDIO_CHANNEL_OUT_3POINT1,AUDIO_CHANNEL_OUT_QUAD,AUDIO_CHANNEL_OUT_SURROUND,AUDIO_CHANNEL_OUT_PENTA,AUDIO_CHANNEL_OUT_5POINT1,AUDIO_CHANNEL_OUT_7POINT1"/>
	<profile name="dts raw" format="AUDIO_FORMAT_DTS"
			 samplingRates="22050,24000,32000,44100,48000,88200,96000,192000"
			 channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_2POINT1,AUDIO_CHANNEL_OUT_TRI,AUDIO_CHANNEL_OUT_QUAD_BACK,AUDIO_CHANNEL_OUT_QUAD_SIDE,AUDIO_CHANNEL_OUT_PENTA,AUDIO_CHANNEL_OUT_5POINT1,AUDIO_CHANNEL_OUT_6POINT1,AUDIO_CHANNEL_OUT_7POINT1"/>
	<profile name="dtshd raw" format="AUDIO_FORMAT_DTS_HD"
			 samplingRates="22050,24000,32000,44100,48000,88200,96000,192000"
			 channelMasks="AUDIO_CHANNEL_OUT_MONO,AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_2POINT1,AUDIO_CHANNEL_OUT_TRI,AUDIO_CHANNEL_OUT_QUAD_BACK,AUDIO_CHANNEL_OUT_QUAD_SIDE,AUDIO_CHANNEL_OUT_PENTA,AUDIO_CHANNEL_OUT_5POINT1,AUDIO_CHANNEL_OUT_6POINT1,AUDIO_CHANNEL_OUT_7POINT1"/>
	<profile name="iec raw" format="AUDIO_FORMAT_IEC61937"
			 samplingRates="8000,11025,16000,22050,24000,32000,44100,48000,128000,176400,192000"
			 channelMasks="AUDIO_CHANNEL_OUT_STEREO,AUDIO_CHANNEL_OUT_5POINT1,AUDIO_CHANNEL_OUT_7POINT1"/>
</mixPort>
  1. 如果没有定义MixPort的profile,则通过getParameters获取对应设备所支持的能力级生成多条profile字段;
    其中会显示 [dynamic format][dynamic channels][dynamic rates]
dumpsys中显示:
    output 5:
    - name: direct output
    - Profiles:
        Profile 0:[dynamic format][dynamic channels][dynamic rates]
            - this: 0xf4e213f0
        Profile 1:[dynamic format][dynamic channels][dynamic rates]
            - this: 0xf4e120d0
            - format: AUDIO_FORMAT_PCM_16_BIT
        Profile 2:[dynamic format]
            - this: 0xf4e10e60
            - format: AUDIO_FORMAT_PCM_16_BIT
            - sampling rates:32000, 44100, 48000, 88200, 96000, 176400, 192000
            - channel masks:0x0003
audio_policy_configuration.xml中没有定义MixPort的profile:
  <mixPort name="direct output" role="source" flags="AUDIO_OUTPUT_FLAG_DIRECT">
      <profile name=""/>
  </mixPort>
  1. 如果只定义了format、sampling rates、channel masks 3个其中某一个/两个,则只通过getParameters获取没有定义的属性,然后生成多条profile字段;其中会显示 [dynamic channels]
dumpsys中显示:
    output 7:
    - name: mmap_no_irq_out_dynamic
    - Profiles:
        Profile 0:[dynamic channels]
            - this: 0xf4e20e00
            - format: AUDIO_FORMAT_PCM_16_BIT
            - sampling rates:48000
            - channel masks:0x0003
audio_policy_configuration.xml中只定义了MixPort的format和samplingRates属性,没有定义channelMasks:
<mixPort name="mmap_no_irq_out_dynamic" role="source" flags="AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_MMAP_NOIRQ">
    <profile name="" format="AUDIO_FORMAT_PCM_16_BIT"
               samplingRates="48000"/>
</mixPort>

6.2.2、mFlags、maxOpenCount、curOpenCount、maxActiveCount、curActiveCount

    output 3:
    - name: compress offload
...
    - flags: 0x0011 (AUDIO_OUTPUT_FLAG_DIRECT|AUDIO_OUTPUT_FLAG_COMPRESS_OFFLOAD)
    - maxOpenCount: 1 - curOpenCount: 0
    - maxActiveCount: 1 - curActiveCount: 0

6.2.3、mGains【AudioGains】

当前没有在xml配置每个IOProfile的gain。

6.2.4、mSupportedDevices【DeviceVector】

    output 3:
    - name: compress offload
...
    - Supported devices:
      Device 1:
      - tag name: BT SCO
      - type: AUDIO_DEVICE_OUT_BLUETOOTH_SCO
      - supported encapsulation modes: 0      - supported encapsulation metadata types: 0
      Device 2:
      - tag name: BT A2DP Speaker
      - type: AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_SPEAKER
      - supported encapsulation modes: 0      - supported encapsulation metadata types: 0
      Device 3:
      - tag name: BT A2DP Headphones
      - type: AUDIO_DEVICE_OUT_BLUETOOTH_A2DP_HEADPHONES
      - supported encapsulation modes: 0      - supported encapsulation metadata types: 0
...

6.3、mInputProfiles【InputProfileCollection】

跟mOutputProfiles一样,InputProfileCollection和OutputProfileCollection都是同一类型。

typedef Vector<sp<IOProfile> > InputProfileCollection;
typedef Vector<sp<IOProfile> > OutputProfileCollection;
  - inputs:
    input 0:
    - name: primary input
    - Profiles:
        Profile 0:
            - format: AUDIO_FORMAT_PCM_16_BIT
            - sampling rates:8000, 11025, 12000, 16000, 22050, 24000, 32000, 44100, 48000
            - channel masks:0x000c, 0x0010
    - flags: 0x0000 (AUDIO_INPUT_FLAG_NONE)
    - Supported devices:
      Device 1:
      - id: 63
      - tag name: 小米小钢炮蓝牙音箱
      - type: AUDIO_DEVICE_IN_BLUETOOTH_SCO_HEADSET|AUDIO_DEVICE_IN_ALL_SCO
      - supported encapsulation modes: 0      - supported encapsulation metadata types: 0      - address: 74:A3:4A:1E:DD:99
      - name: 小米小钢炮蓝牙音箱
      Device 2:
      - id: 11
      - tag name: Spdif In
      - type: AUDIO_DEVICE_IN_SPDIF
      - supported encapsulation modes: 0      - supported encapsulation metadata types: 0      
......
    - maxOpenCount: 1 - curOpenCount: 0
    - maxActiveCount: 1 - curActiveCount: 0
    input 1:
    - name: echo reference
    - Profiles:
        Profile 0:
            - format: AUDIO_FORMAT_PCM_32_BIT
            - sampling rates:48000
            - channel masks:0x000c, 0x0010
    - flags: 0x0000 (AUDIO_INPUT_FLAG_NONE)

    - maxOpenCount: 1 - curOpenCount: 0
    - maxActiveCount: 1 - curActiveCount: 0

6.4、Declared devices (mDeclaredDevices)【DeviceVector】

当前xml中声明的devicePort

  - Declared devices:
    Device 1:
    - id:  2
    - tag name: Speaker
    - type: AUDIO_DEVICE_OUT_SPEAKER
    - supported encapsulation modes: 0    - supported encapsulation metadata types: 0    - Profiles:
        Profile 0:[dynamic format][dynamic channels][dynamic rates]
    - gains:
      Gain 1:
      - mode: 00000001
      - channel_mask: 00000000
      - min_value: -10000 mB
      - max_value: 0 mB
      - default_value: -6000 mB
      - step_value: 100 mB
      - min_ramp_ms: 0 ms
      - max_ramp_ms: 0 ms
.............
    Device 19:
    - tag name: BLE-In
    - type: AUDIO_DEVICE_IN_BLUETOOTH_BLE
    - supported encapsulation modes: 0    - supported encapsulation metadata types: 0    - Profiles:
        Profile 0:
            - format: AUDIO_FORMAT_PCM_16_BIT
            - sampling rates:16000
            - channel masks:0x0010
  - Dynamic devices:
    Device 1:
    - id: 54
    - tag name: 小米小钢炮蓝牙音箱
    - type: AUDIO_DEVICE_OUT_BLUETOOTH_SCO_HEADSET
    - supported encapsulation modes: 0    - supported encapsulation metadata types: 0    - address: 74:A3:4A:1E:DD:99
    - name: 小米小钢炮蓝牙音箱
    - Profiles:
        Profile 0:
            - format: AUDIO_FORMAT_PCM_16_BIT
            - sampling rates:8000, 16000
            - channel masks:0x0001
...

6.5、Dynamic devices (mDynamicDevices)【DeviceVector】

当前没有接入动态设备。(e.g. rsbumix)

6.6、mRoutes【AudioRouteVector】

对应xml中的“…实例,一条xml的route定义对应一个AudioRoute实例。

<routes>
	<route type="mix" sink="HDMI Out"
		   sources="primary output,tunnel pcm,direct output,Tuner,mmap_no_irq_out,compress offload,tunnel compress offload,tunnel direct output"/>
	<route type="mix" sink="Speaker"
		   sources="primary output,tunnel pcm,direct pcm,BT SCO Headset Mic,Tuner,mmap_no_irq_out,compress offload,tunnel compress offload"/>
	<route type="mix" sink="BT SCO"
	...
</routes>

class AudioRoute  : public virtual RefBase {
...
    PolicyAudioPortVector mSources;
    sp<PolicyAudioPort> mSink;
    audio_route_type_t mType;
};

6.6.1、mType【audio_route_type_t 】

xml中定义 
type="mix"
    - Type: Mix

6.6.2、mSink【PolicyAudioPort】

xml中定义 
sink="HDMI Out"
    - Sink: HDMI Out

6.6.3、mSources【PolicyAudioPortVector 】

mSources其包含了多个sp实例

xml中定义 
sources="primary output,tunnel pcm,direct output,Tuner,mmap_no_irq_out,compress offload,tunnel compress offload,tunnel direct output"/>
    - Sources:
        primary output
        tunnel pcm
        direct output
        Tuner
        mmap_no_irq_out_dynamic
        compress offload
        tunnel compress offload
        tunnel direct output

output 0, output 1, output 2…
input 0, input 1, input 2…
xml中配置的一个mixPort对应一个output或者input
xml中role配置为source的为output,role配置为sink的为input(请看中间MIX部分

【Android Audio】dumpsys media.audio_policy分析【不定期更新文章】_第4张图片

7、所有的SwAudioOutputDescriptor (mOutputs)

Outputs dump:
- Output 13 dump:
 Latency: 64
 Flags 00000002
 ID: 1
 Sampling rate: 48000
 Format: 00000001
 Channels: 00000003
 Devices: {type:0x2,@:}
 Global active count: 0
 Product Strategy id: 19    - ActivityCount: 0, StopTime: 14566175183444,
 Volume Activities id: 1    - ActivityCount: 0, StopTime: 0, , Volume: -35.400, MuteCount: 00
 Volume Activities id: 2    - ActivityCount: 0, StopTime: 0, , Volume: -4.800, MuteCount: 00
 Volume Activities id: 4    - ActivityCount: 0, StopTime: 0, , Volume: -19.312, MuteCount: 00
 Volume Activities id: 5    - ActivityCount: 0, StopTime: 0, , Volume: -18.938, MuteCount: 00
 Volume Activities id: 6    - ActivityCount: 0, StopTime: 34133122973, , Volume: -36.000, MuteCount: 00
 Volume Activities id: 7    - ActivityCount: 0, StopTime: 0, , Volume: -21.600, MuteCount: 00
 Volume Activities id: 8    - ActivityCount: 0, StopTime: 0, , Volume: 0.000, MuteCount: 00
 Volume Activities id: 9    - ActivityCount: 0, StopTime: 0, , Volume: 0.000, MuteCount: 00
 Volume Activities id: 10    - ActivityCount: 0, StopTime: 0, , Volume: -8.700, MuteCount: 00
 Volume Activities id: 11    - ActivityCount: 0, StopTime: 14566175183444, , Volume: -6.000, MuteCount: 00
 Volume Activities id: 12    - ActivityCount: 0, StopTime: 0, , Volume: 0.000, MuteCount: 01
 Volume Activities id: 13    - ActivityCount: 0, StopTime: 0, , Volume: -11.879, MuteCount: 00
 Volume Activities id: 20    - ActivityCount: 0, StopTime: 0, , Volume: -35.500, MuteCount: 00
 Volume Activities id: 23    - ActivityCount: 0, StopTime: 0, , Volume: 0.000, MuteCount: 00
 AudioTrack Clients:
  Client 1:
  - Port Id: 31 Session Id: 17 UID: 1000
  - Format: 00000001 Sampling rate: 48000 Channels: 00000003
  - Attributes: { Content type: AUDIO_CONTENT_TYPE_SONIFICATION Usage: AUDIO_USAGE_ASSISTANCE_SONIFICATION Source: AUDIO_SOURCE_DEFAULT Flags: 0xc00 Tags:  }
  - Preferred Device Id: 00000000
  - State: Inactive
  - Stream: 1 flags: 00000004
  - Refcount: 0
  - DAP Primary Mix: 0x0
  - DAP Secondary Outputs:
  Client 2:
  - Port Id: 33 Session Id: 49 UID: 1000
  - Format: 00000001 Sampling rate: 48000 Channels: 00000003
  - Attributes: { Content type: AUDIO_CONTENT_TYPE_SONIFICATION Usage: AUDIO_USAGE_ASSISTANCE_SONIFICATION Source: AUDIO_SOURCE_DEFAULT Flags: 0xc00 Tags:  }
  - Preferred Device Id: 00000000
  - State: Inactive
  - Stream: 1 flags: 00000004
  - Refcount: 0
  - DAP Primary Mix: 0x0
  - DAP Secondary Outputs:
  Client 3:
  - Port Id: 34 Session Id: 57 UID: 1000
  - Format: 00000001 Sampling rate: 48000 Channels: 00000003
  - Attributes: { Content type: AUDIO_CONTENT_TYPE_SONIFICATION Usage: AUDIO_USAGE_ASSISTANCE_SONIFICATION Source: AUDIO_SOURCE_DEFAULT Flags: 0xc00 Tags:  }
  - Preferred Device Id: 00000000
  - State: Inactive
  - Stream: 1 flags: 00000004
  - Refcount: 0
  - DAP Primary Mix: 0x0
  - DAP Secondary Outputs:

8、所有的AudioInputDescriptor (mInputs)

Inputs dump:
- Input 102 dump:
 ID: 126
 Sampling rate: 48000
 Format: 1
 Channels: 0000000c
 Devices type:0x82000000,@:card=1;device=0;
 Effects:
 AudioRecord Clients:
  Client 1:
  - Port Id: 127 Session Id: 369 UID: 10071
  - Format: 00000005 Sampling rate: 48000 Channels: 0000000c
  - Attributes: { Content type: AUDIO_CONTENT_TYPE_UNKNOWN Usage: AUDIO_USAGE_UNKNOWN Source: AUDIO_SOURCE_VOICE_RECOGNITION Flags: 0x0 Tags:  }
  - Preferred Device Id: 00000000
  - State: Active
  - Source: 6 flags: 00000000
    Effects:

9、所有的音效EffectDescriptor (mEffects)

Total Effects CPU: 70.000000 MIPS, Total Effects memory: 350 KB, Max memory used: 350 KB
Effects:
- Effect 11:
  ID: 11
  I/O: 13
  Music Effect: yes
  Session: 0
  Name: True Surround HD
  Enabled
  Active
- Effect 19:
  ID: 19
  I/O: 13
  Music Effect: yes
  Session: 0
  Name: Virtualsurround
  Enabled
  Active
- Effect 27:
  ID: 27
  I/O: 13
  Music Effect: yes
  Session: 0
  Name: TrebleBass
  Enabled
  Active
- Effect 35:
  ID: 35
  I/O: 13
  Music Effect: yes
  Session: 0
  Name: Hpeq
  Enabled
  Active
- Effect 43:
  ID: 43
  I/O: 13
  Music Effect: yes
  Session: 0
  Name: DBX
  Enabled
  Active
- Effect 51:
  ID: 51
  I/O: 13
  Music Effect: yes
  Session: 0
  Name: Balance
  Enabled
  Active
- Effect 59:
  ID: 59
  I/O: 13
  Music Effect: yes
  Session: 0
  Name: Avl
  Enabled
  Active

10、所有AudioPatch (mAudioPatches)

Audio Patches:
  Patch 1: owner uid 1041, handle 66, af handle 44
    [src  1] Device ID 12 AUDIO_DEVICE_IN_AUX_DIGITAL|AUDIO_DEVICE_IN_HDMI
    [sink 1] Device ID 48 AUDIO_DEVICE_OUT_BLUETOOTH_A2DP
  Patch 2: owner uid 1041, handle 76, af handle 52
    [src  1] Mix ID 1 I/O handle 13
    [sink 1] Device ID 48 AUDIO_DEVICE_OUT_BLUETOOTH_A2DP
  Patch 3: owner uid 1041, handle 128, af handle 116
    [src  1] Device ID 88 AUDIO_DEVICE_IN_USB_HEADSET
    [sink 1] Mix ID 126 I/O handle 102

11、所有AudioPolicyMix (mPolicyMixes)

Audio Policy Mix:

12、所有SourceClientDescriptor (mAudioSources.dump)

Audio sources:

13、(mAllowedCapturePolicies)

 AllowedCapturePolicies:

14、Engine (mEngine->dump)

Policy Engine dump:
  Product Strategies dump:
    -STRATEGY_PHONE (id: 14)
      Selected Device: {type:AUDIO_DEVICE_OUT_BLUETOOTH_A2DP, @:74:A3:4A:1E:DD:99}
       Group: 13 stream: AUDIO_STREAM_VOICE_CALL
        Attributes: { Content type: AUDIO_CONTENT_TYPE_UNKNOWN Usage: AUDIO_USAGE_VOICE_COMMUNICATION Source: AUDIO_SOURCE_DEFAULT Flags: 0x0 Tags:  }
       Group: 3 stream: AUDIO_STREAM_BLUETOOTH_SCO
        Attributes: { Content type: AUDIO_CONTENT_TYPE_UNKNOWN Usage: AUDIO_USAGE_UNKNOWN Source: AUDIO_SOURCE_DEFAULT Flags: 0x4 Tags:  }

    -STRATEGY_SONIFICATION (id: 15)
      Selected Device: {type:AUDIO_DEVICE_OUT_SPEAKER , AUDIO_DEVICE_OUT_BLUETOOTH_A2DP, @:74:A3:4A:1E:DD:99}
       Group: 10 stream: AUDIO_STREAM_RING
        Attributes: { Content type: AUDIO_CONTENT_TYPE_UNKNOWN Usage: AUDIO_USAGE_NOTIFICATION_TELEPHONY_RINGTONE Source: AUDIO_SOURCE_DEFAULT Flags: 0x0 Tags:  }
       Group: 2 stream: AUDIO_STREAM_ALARM
        Attributes: { Content type: AUDIO_CONTENT_TYPE_UNKNOWN Usage: AUDIO_USAGE_ALARM Source: AUDIO_SOURCE_DEFAULT Flags: 0x0 Tags:  }
............

  Preferred devices per product strategy dump:

  Volume Groups dump:
    -AUDIO_STREAM_ACCESSIBILITY (id: 1)
      Volume Curves Streams/Attributes, Curve points Streams for device category (index, attenuation in millibel)
       Streams: AUDIO_STREAM_ACCESSIBILITY(10)
       Attributes: { Content type: AUDIO_CONTENT_TYPE_UNKNOWN Usage: AUDIO_USAGE_ASSISTANCE_ACCESSIBILITY Source: AUDIO_SOURCE_DEFAULT Flags: 0x0 Tags:  }
       DEVICE_CATEGORY_HEADSET : { (  0, -5800),  ( 20, -4000),  ( 60, -1700),  (100,     0) }
       DEVICE_CATEGORY_SPEAKER : { (  0, -5800),  ( 20, -4000),  ( 60, -1700),  (100,     0) }
       DEVICE_CATEGORY_EARPIECE : { (  0, -5800),  ( 20, -4000),  ( 60, -1700),  (100,     0) }
       DEVICE_CATEGORY_EXT_MEDIA : { (  0, -5800),  ( 20, -4000),  ( 60, -1700),  (100,     0) }
        Can be muted  Index Min  Index Max  Index Cur [device : index]...
        true          01         15         0002 : 05, 0004 : 02, 0008 : 02, 0080 : 15, 0400 : 05, 40000 : 06, 4000000 : 04, 40000000 : 05,

    -AUDIO_STREAM_ALARM (id: 2)
      Volume Curves Streams/Attributes, Curve points Streams for device category (index, attenuation in millibel)
       Streams: AUDIO_STREAM_ALARM(4)
       Attributes: { Content type: AUDIO_CONTENT_TYPE_UNKNOWN Usage: AUDIO_USAGE_ALARM Source: AUDIO_SOURCE_DEFAULT Flags: 0x0 Tags:  }
       DEVICE_CATEGORY_HEADSET : { (  0, -4950),  ( 33, -3350),  ( 66, -1700),  (100,     0) }
       DEVICE_CATEGORY_SPEAKER : { (  0, -2970),  ( 33, -2010),  ( 66, -1020),  (100,     0) }
       DEVICE_CATEGORY_EARPIECE : { (  0, -4950),  ( 33, -3350),  ( 66, -1700),  (100,     0) }
       DEVICE_CATEGORY_EXT_MEDIA : { (  0, -5800),  ( 20, -4000),  ( 60, -2100),  (100, -1000) }
        Can be muted  Index Min  Index Max  Index Cur [device : index]...
        true          01         07         0002 : 06, 0400 : 06, 40000000 : 06,

    -AUDIO_STREAM_BLUETOOTH_SCO (id: 3)
      Volume Curves Streams/Attributes, Curve points Streams for device category (index, attenuation in millibel)
       Streams: AUDIO_STREAM_BLUETOOTH_SCO(6)
       Attributes: { Content type: AUDIO_CONTENT_TYPE_UNKNOWN Usage: AUDIO_USAGE_UNKNOWN Source: AUDIO_SOURCE_DEFAULT Flags: 0x4 Tags:  }
       DEVICE_CATEGORY_HEADSET : { (  0, -4200),  ( 33, -2800),  ( 66, -1400),  (100,     0) }
       DEVICE_CATEGORY_SPEAKER : { (  0, -2400),  ( 33, -1600),  ( 66,  -800),  (100,     0) }
       DEVICE_CATEGORY_EARPIECE : { (  0, -4200),  ( 33, -2800),  ( 66, -1400),  (100,     0) }
       DEVICE_CATEGORY_EXT_MEDIA : { (  1, -5800),  ( 20, -4000),  ( 60, -1700),  (100,     0) }
        Can be muted  Index Min  Index Max  Index Cur [device : index]...
        true          00         15         0002 : 07, 0080 : 15, 0400 : 07, 40000000 : 07,
............

    -AUDIO_STREAM_age: AUDIO_USAGE_CALL_ASSISTANT Source: AUDIO_SOURCE_DEFAULT Flags: 0x0 Tags:  }
       DEVICE_CATEGORY_HEADSET : { (  0,     0),  (100,     0) }
       DEVICE_CATEGORY_SPEAKER : { (  0,     0),  (100,     0) }
       DEVICE_CATEGORY_EARPIEog:
  Package manager errors: 0
  - uid= 1000cconsole:/ #

你可能感兴趣的:(Android,Audio,Android,调试,android,c++,音频)