blob: c42bca7b9b26ba9f188b5a6169617dc944df8434 [file] [log] [blame]
Robert Ly35f2fda2013-01-29 16:27:05 -08001page.title=Audio
2@jd:body
3
4<!--
Clay Murphy1b77cc22014-12-17 18:20:06 -08005 Copyright 2014 The Android Open Source Project
Robert Ly35f2fda2013-01-29 16:27:05 -08006
7 Licensed under the Apache License, Version 2.0 (the "License");
8 you may not use this file except in compliance with the License.
9 You may obtain a copy of the License at
10
11 http://www.apache.org/licenses/LICENSE-2.0
12
13 Unless required by applicable law or agreed to in writing, software
14 distributed under the License is distributed on an "AS IS" BASIS,
15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 See the License for the specific language governing permissions and
17 limitations under the License.
18-->
Robert Ly35f2fda2013-01-29 16:27:05 -080019<p>
Glenn Kastenff257d42014-11-10 16:29:03 -080020 Android's audio Hardware Abstraction Layer (HAL) connects the higher-level, audio-specific
Robert Ly35f2fda2013-01-29 16:27:05 -080021 framework APIs in <a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a>
22 to the underlying audio driver and hardware.
23</p>
24
25<p>
26 The following figure and list describe how audio functionality is implemented and the relevant
27 source code that is involved in the implementation:
28</p>
Clay Murphy1b77cc22014-12-17 18:20:06 -080029 <img src="images/audio_hal.png" alt="Audio architecture" id="figure1" />
30<p class="img-caption">
31 <strong>Figure 1.</strong> Android audio architecture
Robert Ly35f2fda2013-01-29 16:27:05 -080032</p>
33<dl>
34 <dt>
35 Application framework
36 </dt>
37 <dd>
38 At the application framework level is the app code, which utilizes the
39 <a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a>
40 APIs to interact with the audio hardware. Internally, this code calls corresponding JNI glue
Clay Murphyc28f2372013-09-25 16:13:40 -070041 classes to access the native code that interacts with the audio hardware.
Robert Ly35f2fda2013-01-29 16:27:05 -080042 </dd>
43 <dt>
44 JNI
45 </dt>
46 <dd>
47 The JNI code associated with <a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a> is located in the
48 <code>frameworks/base/core/jni/</code> and <code>frameworks/base/media/jni</code> directories.
49 This code calls the lower level native code to obtain access to the audio hardware.
50 </dd>
51 <dt>
52 Native framework
53 </dt>
54 <dd>
55 The native framework is defined in <code>frameworks/av/media/libmedia</code> and provides a
56 native equivalent to the <a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a> package. The native framework calls the Binder
57 IPC proxies to obtain access to audio-specific services of the media server.
58 </dd>
59 <dt>
60 Binder IPC
61 </dt>
62 <dd>
63 The Binder IPC proxies facilitate communication over process boundaries. They are located in
64 the <code>frameworks/av/media/libmedia</code> directory and begin with the letter "I".
65 </dd>
66 <dt>
67 Media Server
68 </dt>
69 <dd>
70 The audio services in the media server, located in
71 <code>frameworks/av/services/audioflinger</code>, is the actual code that interacts with your
72 HAL implementations.
73 </dd>
74 <dt>
75 HAL
76 </dt>
77 <dd>
Clay Murphyc28f2372013-09-25 16:13:40 -070078 The HAL defines the standard interface that audio services call into
Robert Ly35f2fda2013-01-29 16:27:05 -080079 and that you must implement to have your audio hardware function correctly. The audio HAL
Clay Murphyc28f2372013-09-25 16:13:40 -070080 interfaces are located in
81<code>hardware/libhardware/include/hardware</code>. See <a
Glenn Kastenff257d42014-11-10 16:29:03 -080082href="{@docRoot}devices/halref/audio_8h_source.html">&lt;hardware/audio.h&gt;</a> for additional details.
Robert Ly35f2fda2013-01-29 16:27:05 -080083 </dd>
84 <dt>
85 Kernel Driver
86 </dt>
87 <dd>
88 The audio driver interacts with the hardware and your implementation of the HAL. You can choose
89 to use ALSA, OSS, or a custom driver of your own at this level. The HAL is driver-agnostic.
90 <p>
91 <strong>Note:</strong> If you do choose ALSA, we recommend using <code>external/tinyalsa</code>
92 for the user portion of the driver because of its compatible licensing (The standard user-mode
93 library is GPL licensed).
94</p>
95 </dd>
96</dl>
Glenn Kastenff257d42014-11-10 16:29:03 -080097<p>
98Not shown: Android native audio based on OpenSL ES.
99This API is exposed as part of
100<a href="https://developer.android.com/tools/sdk/ndk/index.html">Android NDK</a>,
101and is at the same architecture level as
102<a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a>.
103</p>
Clay Murphy47b1d3f2013-10-03 10:02:22 -0700104
Robert Ly35f2fda2013-01-29 16:27:05 -0800105<p>
Clay Murphy47b1d3f2013-10-03 10:02:22 -0700106 See the rest of the pages within the Audio section for implementation
107 instructions and ways to improve performance.
Robert Ly35f2fda2013-01-29 16:27:05 -0800108</p>