Starting March 27, 2025, we recommend using android-latest-release
instead of aosp-main
to build and contribute to AOSP. For more information, see Changes to AOSP.
Audio
Stay organized with collections
Save and categorize content based on your preferences.
Android's audio Hardware Abstraction Layer (HAL) connects the higher-level,
audio-specific framework APIs in android.media to the underlying audio driver and
hardware. This section includes implementation instructions and tips for
improving performance.
Android audio architecture defines how audio functionality is implemented and
points to the relevant source code involved in the implementation.
Figure 1. Android audio architecture
-
Application framework
-
The application framework includes the app code, which uses the android.media APIs to
interact with audio hardware. Internally, this code calls corresponding JNI glue
classes to access the native code that interacts with audio hardware.
-
JNI
-
The JNI code associated with android.media calls lower level native code to access audio
hardware. JNI is located in
frameworks/base/core/jni/
and
frameworks/base/media/jni
.
-
Native framework
-
The native framework provides a native equivalent to the android.media package, calling
Binder IPC proxies to access the audio-specific services of the media server.
Native framework code is located in
frameworks/av/media/libmedia
.
-
Binder IPC
-
Binder IPC proxies facilitate communication over process boundaries. Proxies are
located in
frameworks/av/media/libmedia
and begin with the letter
"I".
-
Media server
-
The media server contains audio services, which are the actual code that
interacts with your HAL implementations. The media server is located in
frameworks/av/services/audioflinger
.
-
HAL
-
The HAL defines the standard interface that audio services call into and that
you must implement for your audio hardware to function correctly. For more details, refer to the audio HAL
interface and comments in the
*.hal
files of the corresponding HAL version directory.
-
Kernel driver
-
The audio driver interacts with your hardware and HAL implementation. You can
use Advanced Linux Sound Architecture (ALSA), Open Sound System (OSS), or a
custom driver (HAL is driver-agnostic).
Note: If you use ALSA, we recommend
external/tinyalsa
for the user portion of the driver because of its
compatible licensing (the standard user-mode library is GPL-licensed).
-
Android native audio based on Open SL ES (not shown)
-
This API is exposed as part of
Android NDK
and is at the same architecture level as
android.media.
Content and code samples on this page are subject to the licenses described in the Content License. Java and OpenJDK are trademarks or registered trademarks of Oracle and/or its affiliates.
Last updated 2025-06-18 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-18 UTC."],[],[],null,["# Audio\n\nAndroid's audio Hardware Abstraction Layer (HAL) connects the higher-level,\naudio-specific framework APIs in [android.media](http://developer.android.com/reference/android/media/package-summary.html) to the underlying audio driver and\nhardware. This section includes implementation instructions and tips for\nimproving performance.\n\n\nAndroid audio architecture defines how audio functionality is implemented and\npoints to the relevant source code involved in the implementation.\n\n\n**Figure 1.** Android audio architecture\n\n\nApplication framework\n:\n The application framework includes the app code, which uses the [android.media](http://developer.android.com/reference/android/media/package-summary.html) APIs to\n interact with audio hardware. Internally, this code calls corresponding JNI glue\n classes to access the native code that interacts with audio hardware.\n\n\nJNI\n:\n The JNI code associated with [android.media](http://developer.android.com/reference/android/media/package-summary.html) calls lower level native code to access audio\n hardware. JNI is located in `frameworks/base/core/jni/` and\n `frameworks/base/media/jni`.\n\n\nNative framework\n:\n The native framework provides a native equivalent to the [android.media](http://developer.android.com/reference/android/media/package-summary.html) package, calling\n Binder IPC proxies to access the audio-specific services of the media server.\n Native framework code is located in `frameworks/av/media/libmedia`.\n\n\nBinder IPC\n:\n Binder IPC proxies facilitate communication over process boundaries. Proxies are\n located in `frameworks/av/media/libmedia` and begin with the letter\n \"I\".\n\n\nMedia server\n:\n The media server contains audio services, which are the actual code that\n interacts with your HAL implementations. The media server is located in\n `frameworks/av/services/audioflinger`.\n\n\nHAL\n:\n The HAL defines the standard interface that audio services call into and that\n you must implement for your audio hardware to function correctly. For more details, refer to the [audio HAL\n interface](https://android.googlesource.com/platform/hardware/interfaces/+/refs/heads/android16-release/audio/) and comments in the `*.hal` files of the corresponding HAL version directory.\n\n\nKernel driver\n\n: The audio driver interacts with your hardware and HAL implementation. You can use Advanced Linux Sound Architecture (ALSA), Open Sound System (OSS), or a custom driver (HAL is driver-agnostic). **Note** : If you use ALSA, we recommend\n `external/tinyalsa` for the user portion of the driver because of its\n compatible licensing (the standard user-mode library is GPL-licensed).\n\n\nAndroid native audio based on Open SL ES *(not shown)*\n:\n This API is exposed as part of\n [Android NDK](https://developer.android.com/tools/sdk/ndk/index.html)\n and is at the same architecture level as\n [android.media](http://developer.android.com/reference/android/media/package-summary.html)."]]