【Android Audio】dumpsys audio分析【不定期更新文章】

牟华翰
2023-12-01

命令:
dumpsys audio

Message handler (watch for unhandled messages):
  Handler (com.android.server.audio.AudioService$AudioHandler) {4adb93d} @ 5038924
    Looper (AudioService, tid 87) {e96a532}
      (Total messages: 0, polling=true, quitting=false)

MediaFocusControl dump time: 4:41:27 PM

Audio Focus stack entries (last is top of stack):
  source:android.os.BinderProxy@325c283 -- pack: com.droidlogic.android.tv -- client: android.media.AudioManager@9f322afcom.android.tv.AudioManagerHelper@37146bc -- gain: GAIN -- flags:  -- loss: none -- notified: true -- uid: 10059 -- attr: AudioAttributes: usage=USAGE_MEDIA content=CONTENT_TYPE_MUSIC flags=0x800 tags= bundle=null -- sdk:29


No external focus policy



 Notify on duck:  true

 In ring or call: false



Audio event log: focus commands as seen by MediaFocusControl
07-19 15:18:59:992 requestAudioFocus() from uid/pid 10059/857 clientId=android.media.AudioManager@9f322afcom.android.tv.AudioManagerHelper@37146bc callingPack=com.droidlogic.android.tv req=1 flags=0x0 sdk=29
07-19 15:27:24:248 abandonAudioFocus() from uid/pid 10059/857 clientId=android.media.AudioManager@9f322afcom.android.tv.AudioManagerHelper@37146bc
07-19 15:27:33:864 requestAudioFocus() from uid/pid 10059/857 clientId=android.media.AudioManager@9f322afcom.android.tv.AudioManagerHelper@37146bc callingPack=com.droidlogic.android.tv req=1 flags=0x0 sdk=29
Multi Audio Focus enabled :false

显示当前所有stream type的音量状态

以STREAM_MUSIC为例

Stream volumes (device: index)
...
- STREAM_RING:
   Muted: false
   Muted Internally: false
   Min: 0
   Max: 7
   streamVolume:5
   Current: 2 (speaker): 5, 80 (bt_a2dp): 5, 400 (hdmi): 5, 40000000 (default): 5
   Devices: speaker, bt_a2dp
- STREAM_MUSIC: \\ volume type
   Muted: false   \\ 当前mute状态
   Muted Internally: false
   Min: 0     \\ UI可设置的最小音量
   Max: 25    \\ UI可设置的最大音量
   streamVolume:22  \\ 当前UI音量
   Current: 2 (speaker): 18, 4 (headset): 10, 8 (headphone): 10, 80 (bt_a2dp): 22, 400 (hdmi): 21, 4000000 (usb_headset): 5, 40000000 (default): 20 \\ 当前该stream支持的设备和其对应的音量值
   Devices: bt_a2dp  \\ 当前输出设备
...
- mute affected streams = 0x6f

Volume Groups (device: index)
- VOLUME GROUP AUDIO_STREAM_ACCESSIBILITY:
   Min: 1
   Max: 15
   Current: 40000000 (default): 12
   Devices: bt_a2dp
- VOLUME GROUP AUDIO_STREAM_ALARM:
   Min: 1
   Max: 7
   Current: 40000000 (default): 6
   Devices: bt_a2dp
- VOLUME GROUP AUDIO_STREAM_DTMF:
   Min: 0
   Max: 15
   Current: 40000000 (default): 12
   Devices: bt_a2dp
- VOLUME GROUP AUDIO_STREAM_ENFORCED_AUDIBLE:
   Min: 0
   Max: 7
   Current: 40000000 (default): 6
   Devices: bt_a2dp
- VOLUME GROUP AUDIO_STREAM_MUSIC:
   Min: 0
   Max: 25
   Current: 40000000 (default): 20
   Devices: bt_a2dp
- VOLUME GROUP AUDIO_STREAM_NOTIFICATION:
   Min: 0
   Max: 7
   Current: 40000000 (default): 6
   Devices: bt_a2dp
- VOLUME GROUP AUDIO_STREAM_RING:
   Min: 0
   Max: 7
   Current: 40000000 (default): 5
   Devices: bt_a2dp
- VOLUME GROUP AUDIO_STREAM_SYSTEM:
   Min: 0
   Max: 7
   Current: 40000000 (default): 7
   Devices: bt_a2dp
- VOLUME GROUP AUDIO_STREAM_VOICE_CALL:
   Min: 1
   Max: 5
   Current: 40000000 (default): 4
   Devices: bt_a2dp
- VOLUME GROUP AUDIO_STREAM_ASSISTANT:
   Min: 0
   Max: 15
   Current: 40000000 (default): 12
   Devices: bt_a2dp
- VOLUME GROUP AUDIO_STREAM_CALL_ASSISTANT:
   Min: 0
   Max: 25
   Current: 40000000 (default): 20
   Devices: bt_a2dp

Ringer mode:
- mode (internal) = NORMAL
- mode (external) = NORMAL
- zen mode:ZEN_MODE_OFF
- ringer mode affected streams = 0x80 (STREAM_SYSTEM_ENFORCED)
- ringer mode muted streams = 0x0
- delegate = ZenModeHelper

Audio routes:
  mMainType=0x8
  mBluetoothName=SRS-XB12

Other state:
  mVolumeController=VolumeController(android.os.BinderProxy@f384e20,mVisible=false)
  mSafeMediaVolumeState=SAFE_MEDIA_VOLUME_ACTIVE
  mSafeMediaVolumeIndex=100
  mSafeUsbMediaVolumeIndex=50
  mSafeUsbMediaVolumeDbfs=-37.0
  sIndependentA11yVolume=false
  mPendingVolumeCommand=null
  mMusicActiveMs=0
  mMcc=0
  mCameraSoundForced=false
  mHasVibrator=false
  mVolumePolicy=VolumePolicy[volumeDownToEnterSilent=false,volumeUpToExitSilent=false,doNotDisturbWhenSilent=false,vibrateToSilentDebounce=400]
  mAvrcpAbsVolSupported=true
  mIsSingleVolume=true
  mUseFixedVolume=false
  mFixedVolumeDevices=0x1000,0x800,0x200000,0x40000
  mExtVolumeController=null
  mHdmiCecSink=true
  mHdmiAudioSystemClient=null
  mHdmiPlaybackClient=android.hardware.hdmi.HdmiPlaybackClient@ca9ec00
  mHdmiTvClient=null
  mHdmiSystemAudioSupported=false
  mHdmiCecVolumeControlEnabled=true
  mVolumePassthroughEnabled=true
  mSupportDolbyMS12=true
  mInVolumePassthrough=false
  mIsCallScreeningModeSupported=false
  mic mute FromSwitch=false FromRestrictions=false FromApi=false from system=false
Audio policies:
Audio event log: dynamic policy events (logged when command received by AudioService)

PlaybackActivityMonitor dump time: 4:41:27 PM

  playback listeners:
 (S)com.android.server.audio.PlaybackActivityMonitor$PlayMonitorClient@241ac39 (S)com.android.server.audio.PlaybackActivityMonitor$PlayMonitorClient@585e27e


  players:
  AudioPlaybackConfiguration piid:15 type:android.media.SoundPool u/pid:1000/616 state:idle attr:AudioAttributes: usage=USAGE_ASSISTANCE_SONIFICATION content=CONTENT_TYPE_SONIFICATION flags=0x800 tags= bundle=null

  ducked players piids:

  muted player piids:

  banned uids:

Audio event log: playback activity as reported through PlayerBase
07-19 15:17:46:651 new player piid:15 uid/pid:1000/616 type:android.media.SoundPool attr:AudioAttributes: usage=USAGE_ASSISTANCE_SONIFICATION content=CONTENT_TYPE_SONIFICATION flags=0x800 tags= bundle=null
07-19 15:18:12:647 new player piid:31 uid/pid:10052/2531 type:unknown attr:AudioAttributes: usage=USAGE_MEDIA content=CONTENT_TYPE_UNKNOWN flags=0x1400 tags= bundle=null
07-19 15:18:12:751 releasing player piid:31
07-19 15:18:56:794 player piid:15 state:started
07-19 15:18:57:017 player piid:15 state:started
07-19 15:18:57:296 player piid:15 state:started
07-19 15:18:58:314 player piid:15 state:started
07-19 15:18:58:737 player piid:15 state:started
07-19 15:18:59:329 player piid:15 state:started
07-19 15:27:21:569 player piid:15 state:started
07-19 15:27:21:848 player piid:15 state:started
07-19 15:27:22:672 player piid:15 state:started
07-19 15:27:22:961 player piid:15 state:started
07-19 15:27:23:361 player piid:15 state:started
07-19 15:27:23:415 player piid:15 state:started
07-19 15:27:23:457 player piid:15 state:started
07-19 15:27:23:508 player piid:15 state:started
07-19 15:27:23:565 player piid:15 state:started
07-19 15:27:24:175 player piid:15 state:started
07-19 15:27:26:114 player piid:15 state:started
07-19 15:27:28:168 player piid:15 state:started
07-19 15:27:28:843 player piid:15 state:started
07-19 15:27:30:303 player piid:15 state:started
07-19 15:27:30:586 player piid:15 state:started
07-19 15:27:31:301 player piid:15 state:started

  allowed capture policies:
  uid: 10052 policy: 3

RecordActivityMonitor dump time: 4:41:27 PM


Audio event log: recording activity received by AudioService

显示AudioDeviceBroker状态

AudioDeviceBroker:
  Message handler (watch for unhandled messages):
    Handler (com.android.server.audio.AudioDeviceBroker$BrokerHandler) {7803df} @ 5038939
      Looper (AudioDeviceBroker, tid 88) {1c1c82c}
        (Total messages: 0, polling=true, quitting=false)

  Preferred devices for strategy:

  Connected devices:  \\ 当前平台连接的设备
    [DeviceInfo: type:0x400 (hdmi) name: addr: codec: 0]
    [DeviceInfo: type:0x84000000 (bt_ble) name:SRS-XB12 addr:04:21:44:21:88:E9 codec: 0]
    [DeviceInfo: type:0x10 (bt_sco) name:SRS-XB12 addr:04:21:44:21:88:E9 codec: 0]
    [DeviceInfo: type:0x80000008 (bt_sco_hs) name:SRS-XB12 addr:04:21:44:21:88:E9 codec: 0]
    [DeviceInfo: type:0x80 (bt_a2dp) name:SRS-XB12 addr:04:21:44:21:88:E9 codec: 4000000]

  APM Connected device (A2DP sink only):
     type:0x80 (bt_a2dp) addr:0x80:04:21:44:21:88:E9

  mForcedUseForComm: FORCE_NONE
  mForcedUseForCommExt: FORCE_NONE
  mModeOwnerPid: 0
  Speakerphone clients:

  mBluetoothHeadset: android.bluetooth.BluetoothHeadset@887d2f5
  mBluetoothHeadsetDevice: 04:21:44:21:88:E9
  mScoAudioState: SCO_STATE_INACTIVE
  mScoAudioMode: SCO_MODE_VIRTUAL_CALL
  Sco clients:

  mHearingAid: null
  mA2dp: android.bluetooth.BluetoothA2dp@299a88a
  mAvrcpAbsVolSupported: true

SoundEffects:
  Message handler (watch for unhandled messages):
  Handler (com.android.server.audio.SoundEffectsHelper$SfxHandler) {182fefb} @ 5038939
    Looper (AS.SfxWorker, tid 86) {f993b18}
      (Total messages: 0, polling=true, quitting=false)
  Default attenuation (dB): -6
Audio event log: Sound Effects Loading
07-19 15:17:46:648 effects loading started
07-19 15:17:48:933 effect Effect_Tick.ogg loaded
07-19 15:17:48:938 effect KeypressStandard.ogg loaded
07-19 15:17:49:052 effect KeypressDelete.ogg loaded
07-19 15:17:49:075 effect KeypressSpacebar.ogg loaded
07-19 15:17:49:213 effect KeypressReturn.ogg loaded
07-19 15:17:49:218 effect KeypressInvalid.ogg loaded
07-19 15:17:49:219 effects loading completed



Event logs:
Audio event log: phone state (logged after successful call to AudioSystem.setPhoneState(int, int))

 类似资料: