1 <html devsite> 2 <head> 3 <title>Audio</title> 4 <meta name="project_path" value="/_project.yaml" /> 5 <meta name="book_path" value="/_book.yaml" /> 6 </head> 7 <body> 8 <!-- 9 Copyright 2017 The Android Open Source Project 10 11 Licensed under the Apache License, Version 2.0 (the "License"); 12 you may not use this file except in compliance with the License. 13 You may obtain a copy of the License at 14 15 http://www.apache.org/licenses/LICENSE-2.0 16 17 Unless required by applicable law or agreed to in writing, software 18 distributed under the License is distributed on an "AS IS" BASIS, 19 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 See the License for the specific language governing permissions and 21 limitations under the License. 22 --> 23 24 25 26 <img style="float: right; margin: 0px 15px 15px 15px;" 27 src="images/ape_fwk_hal_audio.png" alt="Android Audio HAL icon"/> 28 29 <p> 30 Android's audio Hardware Abstraction Layer (HAL) connects the higher-level, 31 audio-specific framework APIs in <a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a> to the underlying audio driver and 32 hardware. This section includes implementation instructions and tips for 33 improving performance. 34 </p> 35 36 <h2 id="Architecture">Audio Architecture</h2> 37 <p> 38 Android audio architecture defines how audio functionality is implemented and 39 points to the relevant source code involved in the implementation. 40 </p> 41 42 <img src="images/ape_fwk_audio.png" alt="Audio architecture" id="figure1" /> 43 44 <p class="img-caption"> 45 <strong>Figure 1.</strong> Android audio architecture 46 </p> 47 48 <dl> 49 50 <dt> 51 Application framework 52 </dt> 53 <dd> 54 The application framework includes the app code, which uses the <a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a> APIs to 55 interact with audio hardware. Internally, this code calls corresponding JNI glue 56 classes to access the native code that interacts with audio hardware. 57 </dd> 58 59 <dt> 60 JNI 61 </dt> 62 <dd> 63 The JNI code associated with <a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a> calls lower level native code to access audio 64 hardware. JNI is located in <code>frameworks/base/core/jni/</code> and 65 <code>frameworks/base/media/jni</code>. 66 </dd> 67 68 <dt> 69 Native framework 70 </dt> 71 <dd> 72 The native framework provides a native equivalent to the <a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a> package, calling 73 Binder IPC proxies to access the audio-specific services of the media server. 74 Native framework code is located in <code>frameworks/av/media/libmedia</code>. 75 </dd> 76 77 <dt> 78 Binder IPC 79 </dt> 80 <dd> 81 Binder IPC proxies facilitate communication over process boundaries. Proxies are 82 located in <code>frameworks/av/media/libmedia</code> and begin with the letter 83 "I". 84 </dd> 85 86 <dt> 87 Media server 88 </dt> 89 <dd> 90 The media server contains audio services, which are the actual code that 91 interacts with your HAL implementations. The media server is located in 92 <code>frameworks/av/services/audioflinger</code>. 93 </dd> 94 95 <dt> 96 HAL 97 </dt> 98 <dd> 99 The HAL defines the standard interface that audio services call into and that 100 you must implement for your audio hardware to function correctly. The audio HAL 101 interfaces are located in <code>hardware/libhardware/include/hardware</code>. 102 For details, see <a 103 href="https://android.googlesource.com/platform/hardware/libhardware/+/master/include/hardware/audio.h">audio.h</a>. 104 </dd> 105 106 <dt> 107 Kernel driver 108 </dt> 109 <dd> 110 The audio driver interacts with your hardware and HAL implementation. You can 111 use Advanced Linux Sound Architecture (ALSA), Open Sound System (OSS), or a 112 custom driver (HAL is driver-agnostic). 113 <p class="note"><strong>Note</strong>: If you use ALSA, we recommend 114 <code>external/tinyalsa</code> for the user portion of the driver because of its 115 compatible licensing (the standard user-mode library is GPL-licensed).</p> 116 </dd> 117 118 <dt> 119 Android native audio based on Open SL ES <em>(not shown)</em> 120 </dt> 121 <dd> 122 This API is exposed as part of 123 <a href="https://developer.android.com/tools/sdk/ndk/index.html">Android NDK</a> 124 and is at the same architecture level as 125 <a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a>. 126 </dd> 127 128 </dl> 129 130 </body> 131 </html> 132