blob: 82a3886d5053481cd7e6dae609aca2fc785ff158 [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
Heidi von Markham83132e72015-04-13 17:04:50 -070020<img style="float: right; margin: 0px 15px 15px 15px;"
21src="images/ape_fwk_hal_audio.png" alt="Android Audio HAL icon"/>
22
Robert Ly35f2fda2013-01-29 16:27:05 -080023<p>
Heidi von Markham83132e72015-04-13 17:04:50 -070024Android's audio Hardware Abstraction Layer (HAL) connects the higher-level,
25audio-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
26hardware. This section includes implementation instructions and tips for
27improving performance.
Robert Ly35f2fda2013-01-29 16:27:05 -080028</p>
Heidi von Markham83132e72015-04-13 17:04:50 -070029
Heidi von Markham1e7b8b72015-03-09 10:13:48 -070030<h2 id="Architecture">Audio Architecture</h2>
Robert Ly35f2fda2013-01-29 16:27:05 -080031<p>
Heidi von Markham83132e72015-04-13 17:04:50 -070032Android audio architecture defines how audio functionality is implemented and
33points to the relevant source code involved in the implementation.
Robert Ly35f2fda2013-01-29 16:27:05 -080034</p>
Heidi von Markham83132e72015-04-13 17:04:50 -070035
36<img src="images/ape_fwk_audio.png" alt="Audio architecture" id="figure1" />
37
Clay Murphy1b77cc22014-12-17 18:20:06 -080038<p class="img-caption">
Heidi von Markham83132e72015-04-13 17:04:50 -070039<strong>Figure 1.</strong> Android audio architecture
Robert Ly35f2fda2013-01-29 16:27:05 -080040</p>
Heidi von Markham83132e72015-04-13 17:04:50 -070041
Robert Ly35f2fda2013-01-29 16:27:05 -080042<dl>
Heidi von Markham83132e72015-04-13 17:04:50 -070043
44<dt>
45Application framework
46</dt>
47<dd>
48The 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
49interact with audio hardware. Internally, this code calls corresponding JNI glue
50classes to access the native code that interacts with audio hardware.
51</dd>
52
53<dt>
54JNI
55</dt>
56<dd>
57The 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
58hardware. JNI is located in <code>frameworks/base/core/jni/</code> and
59<code>frameworks/base/media/jni</code>.
60</dd>
61
62<dt>
63Native framework
64</dt>
65<dd>
66The 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
67Binder IPC proxies to access the audio-specific services of the media server.
68Native framework code is located in <code>frameworks/av/media/libmedia</code>.
69</dd>
70
71<dt>
72Binder IPC
73</dt>
74<dd>
75Binder IPC proxies facilitate communication over process boundaries. Proxies are
76located in <code>frameworks/av/media/libmedia</code> and begin with the letter
77"I".
78</dd>
79
80<dt>
81Media server
82</dt>
83<dd>
84The media server contains audio services, which are the actual code that
85interacts with your HAL implementations. The media server is located in
86<code>frameworks/av/services/audioflinger</code>.
87</dd>
88
89<dt>
90HAL
91</dt>
92<dd>
93The HAL defines the standard interface that audio services call into and that
94you must implement for your audio hardware to function correctly. The audio HAL
95interfaces are located in <code>hardware/libhardware/include/hardware</code>.
96For details, see <a
97href="{@docRoot}devices/halref/audio_8h_source.html">hardware/audio.h</a>.
98</dd>
99
100<dt>
101Kernel driver
102</dt>
103<dd>
104The audio driver interacts with your hardware and HAL implementation. You can
105use Advanced Linux Sound Architecture (ALSA), Open Sound System (OSS), or a
106custom driver (HAL is driver-agnostic).
107<p class="note"><strong>Note</strong>: If you use ALSA, we recommend
108<code>external/tinyalsa</code> for the user portion of the driver because of its
109compatible licensing (the standard user-mode library is GPL-licensed).</p>
110</dd>
111
112<dt>
113Android native audio based on Open SL ES <em>(not shown)</em>
114</dt>
115<dd>
Glenn Kastenff257d42014-11-10 16:29:03 -0800116This API is exposed as part of
Heidi von Markham83132e72015-04-13 17:04:50 -0700117<a href="https://developer.android.com/tools/sdk/ndk/index.html">Android NDK</a>
Glenn Kastenff257d42014-11-10 16:29:03 -0800118and is at the same architecture level as
119<a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a>.
Heidi von Markham83132e72015-04-13 17:04:50 -0700120</dd>
121
Clay Murphyd6020bf2015-07-13 12:09:45 -0700122</dl>