1page.title=Audio
2@jd:body
3
4<!--
5    Copyright 2013 The Android Open Source Project
6
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-->
19<p>
20  Android's audio Hardware Abstraction Layer (HAL) connects the higher level, audio-specific
21  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>
29<p>
30  <img src="images/audio_hal.png" alt="Audio architecture" />
31</p>
32<dl>
33  <dt>
34    Application framework
35  </dt>
36  <dd>
37    At the application framework level is the app code, which utilizes the
38    <a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a>
39    APIs to interact with the audio hardware. Internally, this code calls corresponding JNI glue
40    classes to access the native code that interacts with the audio hardware.
41  </dd>
42  <dt>
43    JNI
44  </dt>
45  <dd>
46    The JNI code associated with <a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a> is located in the
47    <code>frameworks/base/core/jni/</code> and <code>frameworks/base/media/jni</code> directories.
48    This code calls the lower level native code to obtain access to the audio hardware.
49  </dd>
50  <dt>
51    Native framework
52  </dt>
53  <dd>
54    The native framework is defined in <code>frameworks/av/media/libmedia</code> and provides a
55    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
56    IPC proxies to obtain access to audio-specific services of the media server.
57  </dd>
58  <dt>
59    Binder IPC
60  </dt>
61  <dd>
62    The Binder IPC proxies facilitate communication over process boundaries. They are located in
63    the <code>frameworks/av/media/libmedia</code> directory and begin with the letter "I".
64  </dd>
65  <dt>
66    Media Server
67  </dt>
68  <dd>
69    The audio services in the media server, located in
70    <code>frameworks/av/services/audioflinger</code>, is the actual code that interacts with your
71    HAL implementations.
72  </dd>
73  <dt>
74    HAL
75  </dt>
76  <dd>
77    The HAL defines the standard interface that audio services call into
78    and that you must implement to have your audio hardware function correctly. The audio HAL
79    interfaces are located in
80<code>hardware/libhardware/include/hardware</code>. See <a
81href="{@docRoot}devices/halref/audio_8h_source.html">audio.h</a> for additional details.
82  </dd>
83  <dt>
84    Kernel Driver
85  </dt>
86  <dd>
87    The audio driver interacts with the hardware and your implementation of the HAL. You can choose
88    to use ALSA, OSS, or a custom driver of your own at this level. The HAL is driver-agnostic.
89    <p>
90  <strong>Note:</strong> If you do choose ALSA, we recommend using <code>external/tinyalsa</code>
91  for the user portion of the driver because of its compatible licensing (The standard user-mode
92  library is GPL licensed).
93</p>
94  </dd>
95</dl>
96
97<p>
98   See the rest of the pages within the Audio section for implementation
99   instructions and ways to improve performance.
100</p>
101