blob: bfa616d57e23b26fb0868c17852af89b13667c99 [file] [log] [blame]
Robert Ly35f2fda2013-01-29 16:27:05 -08001page.title=Audio
2@jd:body
3
4<!--
Heidi von Markham1e7b8b72015-03-09 10:13:48 -07005 Copyright 2015 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-->
Heidi von Markham1e7b8b72015-03-09 10:13:48 -070019
20<div id="qv-wrapper">
21 <div id="qv">
22 <h2>In this document</h2>
23 <ol id="auto-toc">
24 </ol>
25 </div>
26</div>
27
Heidi von Markham83132e72015-04-13 17:04:50 -070028<img style="float: right; margin: 0px 15px 15px 15px;"
29src="images/ape_fwk_hal_audio.png" alt="Android Audio HAL icon"/>
30
Robert Ly35f2fda2013-01-29 16:27:05 -080031<p>
Heidi von Markham83132e72015-04-13 17:04:50 -070032Android's audio Hardware Abstraction Layer (HAL) connects the higher-level,
33audio-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
34hardware. This section includes implementation instructions and tips for
35improving performance.
Robert Ly35f2fda2013-01-29 16:27:05 -080036</p>
Heidi von Markham83132e72015-04-13 17:04:50 -070037
Heidi von Markham1e7b8b72015-03-09 10:13:48 -070038<h2 id="Architecture">Audio Architecture</h2>
Robert Ly35f2fda2013-01-29 16:27:05 -080039<p>
Heidi von Markham83132e72015-04-13 17:04:50 -070040Android audio architecture defines how audio functionality is implemented and
41points to the relevant source code involved in the implementation.
Robert Ly35f2fda2013-01-29 16:27:05 -080042</p>
Heidi von Markham83132e72015-04-13 17:04:50 -070043
44<img src="images/ape_fwk_audio.png" alt="Audio architecture" id="figure1" />
45
Clay Murphy1b77cc22014-12-17 18:20:06 -080046<p class="img-caption">
Heidi von Markham83132e72015-04-13 17:04:50 -070047<strong>Figure 1.</strong> Android audio architecture
Robert Ly35f2fda2013-01-29 16:27:05 -080048</p>
Heidi von Markham83132e72015-04-13 17:04:50 -070049
Robert Ly35f2fda2013-01-29 16:27:05 -080050<dl>
Heidi von Markham83132e72015-04-13 17:04:50 -070051
52<dt>
53Application framework
54</dt>
55<dd>
56The 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
57interact with audio hardware. Internally, this code calls corresponding JNI glue
58classes to access the native code that interacts with audio hardware.
59</dd>
60
61<dt>
62JNI
63</dt>
64<dd>
65The 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
66hardware. JNI is located in <code>frameworks/base/core/jni/</code> and
67<code>frameworks/base/media/jni</code>.
68</dd>
69
70<dt>
71Native framework
72</dt>
73<dd>
74The 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
75Binder IPC proxies to access the audio-specific services of the media server.
76Native framework code is located in <code>frameworks/av/media/libmedia</code>.
77</dd>
78
79<dt>
80Binder IPC
81</dt>
82<dd>
83Binder IPC proxies facilitate communication over process boundaries. Proxies are
84located in <code>frameworks/av/media/libmedia</code> and begin with the letter
85"I".
86</dd>
87
88<dt>
89Media server
90</dt>
91<dd>
92The media server contains audio services, which are the actual code that
93interacts with your HAL implementations. The media server is located in
94<code>frameworks/av/services/audioflinger</code>.
95</dd>
96
97<dt>
98HAL
99</dt>
100<dd>
101The HAL defines the standard interface that audio services call into and that
102you must implement for your audio hardware to function correctly. The audio HAL
103interfaces are located in <code>hardware/libhardware/include/hardware</code>.
104For details, see <a
105href="{@docRoot}devices/halref/audio_8h_source.html">hardware/audio.h</a>.
106</dd>
107
108<dt>
109Kernel driver
110</dt>
111<dd>
112The audio driver interacts with your hardware and HAL implementation. You can
113use Advanced Linux Sound Architecture (ALSA), Open Sound System (OSS), or a
114custom driver (HAL is driver-agnostic).
115<p class="note"><strong>Note</strong>: If you use ALSA, we recommend
116<code>external/tinyalsa</code> for the user portion of the driver because of its
117compatible licensing (the standard user-mode library is GPL-licensed).</p>
118</dd>
119
120<dt>
121Android native audio based on Open SL ES <em>(not shown)</em>
122</dt>
123<dd>
Glenn Kastenff257d42014-11-10 16:29:03 -0800124This API is exposed as part of
Heidi von Markham83132e72015-04-13 17:04:50 -0700125<a href="https://developer.android.com/tools/sdk/ndk/index.html">Android NDK</a>
Glenn Kastenff257d42014-11-10 16:29:03 -0800126and is at the same architecture level as
127<a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a>.
Heidi von Markham83132e72015-04-13 17:04:50 -0700128</dd>
129
130</dl>