The Android audio architecture is a sophisticated, multi-tiered framework responsible for routing sound from active mobile applications, games, phone calls, and alarms to various physical and wireless transducers. Modern smartphones dynamically multiplex audio streams across internal stereo speakers, phone earpieces, USB-C digital audio interfaces, 3.5mm headphone jacks, and Bluetooth A2DP audio peripherals. When audio output routes to the wrong hardware endpoint, volume attenuation fails during notifications, or spatial audio channels drop, inspecting the underlying audio policy manager is required.
The Android Debug Bridge (ADB) provides full diagnostic transparency into this subsystem via the dumpsys media.audio_policy command. By executing this command, Android developers, ROM engineers, and power users can inspect the complete audio routing matrix, active hardware output profiles, volume gain curves, dynamic audio mixes, and input/output stream handles directly from a connected terminal.
Understanding Android Audio Policy Architecture
In Android, the AudioPolicyService daemon is the core decision-making entity within the media framework. When an application requests an audio track, AudioPolicyService coordinates with the Audio HAL (Hardware Abstraction Layer) to evaluate three critical decisions:
- Routing Decisions: Which physical device (e.g., Speaker, Bluetooth A2DP, Wired Headset) should receive the audio stream based on hardware attachment state and user preference.
- Stream Volume & Attenuation: Calculating the precise output gain curve based on hardware volume keys, media stream classification (Music, Voice Call, Alarm, Notification), and ducking rules.
- Session Concurrency: Deciding whether concurrent audio streams should be mixed together, paused, or dynamically attenuated (ducked) when transient notification chimes occur.
Dumping the Complete Audio Policy Configuration
Connect your Android device to your computer via USB or wireless debugging with USB debugging enabled. In your terminal, run the primary inspection command:
adb shell dumpsys media.audio_policy
Because the generated dump contains extensive configuration arrays, routing maps, and gain tables, save the complete output to a local text file for offline inspection:
adb shell dumpsys media.audio_policy > audio_policy_dump.txt
Inspecting Active Audio Outputs and Hardware Profiles
To determine which physical output devices the operating system currently considers available and active, inspect the hardware output section of the dump:
adb shell dumpsys media.audio_policy | grep -A 20 "Hardware Output Devices"
The report enumerates all available physical output sink devices recognized by the audio HAL:
AUDIO_DEVICE_OUT_SPEAKER(Internal primary loudspeakers)AUDIO_DEVICE_OUT_EARPIECE(Receiver speaker for voice calls)AUDIO_DEVICE_OUT_WIRED_HEADSET(Analog headphone jack)AUDIO_DEVICE_OUT_BLUETOOTH_A2DP(Wireless stereo audio)AUDIO_DEVICE_OUT_USB_DEVICE(External USB DACs and digital interfaces)
Each profile lists its supported sampling rates (e.g., 44.1kHz, 48kHz, 96kHz, 192kHz), channel masks (e.g., Stereo, 5.1, 7.1), and audio encoding formats (e.g., PCM 16-bit, PCM 24-bit, PCM 32-bit, AAC, LDAC).
Auditing Active Playback Streams and Audio Tracks
When an application is actively playing media, its audio stream is assigned a unique I/O handle and routed through an active output descriptor. To identify which applications are holding audio streams open, run:
adb shell dumpsys media.audio_policy | grep -A 25 "Outputs dump:"
Examine the active output descriptor block:
Output 13:
Sampling rate: 48000
Format: 0x1 (AUDIO_FORMAT_PCM_16_BIT)
Channels: 0x3 (AUDIO_CHANNEL_OUT_STEREO)
Latency: 40 ms
Flags: 0x4 (AUDIO_OUTPUT_FLAG_PRIMARY)
Devices: AUDIO_DEVICE_OUT_SPEAKER
Active clients: 1
Session 428: Package com.spotify.music, Stream type: MUSIC
This diagnostic block reveals:
- Latency: The hardware buffer latency in milliseconds. Low-latency outputs (such as gaming audio streams) will display
AUDIO_OUTPUT_FLAG_FASTwith buffer latencies below 10 ms. - Devices: The exact physical transducer receiving the digital stream.
- Session & Package: The specific application process ID and package name holding the output stream open.
Auditing Volume Curves and Stream Attenuation
If you encounter issues where specific audio streams are too quiet or fail to adjust when volume buttons are pressed, inspect the volume curve configuration:
adb shell dumpsys media.audio_policy | grep -A 15 "Stream Volume Curves"
Android maintains independent volume curves for each stream category:
STREAM_VOICE_CALLSTREAM_SYSTEMSTREAM_RINGSTREAM_MUSICSTREAM_ALARMSTREAM_NOTIFICATION
The dump displays the volume index (e.g., 0 to 15 or 0 to 25) alongside the calculated decibel (dB) attenuation level. If an audio stream is muted, the dump explicitly flags IsMuted: true alongside the attenuation factor.
Monitoring Real-Time Audio Routing Switches
To observe how Android switches audio routing dynamically—such as when plugging in USB headphones or connecting a Bluetooth car console—tail the live logcat buffer filtered for audio policy tags:
adb logcat -s AudioPolicyManager AudioPolicyService AudioFlinger
When a peripheral connects, the log outputs immediate state notifications:
AudioPolicyManager: setDeviceConnectionStateInt() device: 0x80 (AUDIO_DEVICE_OUT_BLUETOOTH_A2DP) state: 1
AudioPolicyManager: checkOutputForStrategy() rerouting strategy 0 to device 0x80
By leveraging dumpsys media.audio_policy, audio developers and system integrators can verify DAC sample rates, diagnose rogue background audio wake locks, and troubleshoot complex Bluetooth multi-point audio routing anomalies efficiently.