blob: b658e85392fec9c48140899e5f0913eb1d0de9c0 [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 Markhamb493fb62015-03-25 12:35:11 -070028<img style="float: right; margin: 0px 15px 15px 15px;" src="images/ape_fwk_hal_audio.png" alt="Android Audio HAL icon"/>
Robert Ly35f2fda2013-01-29 16:27:05 -080029<p>
Glenn Kastenff257d42014-11-10 16:29:03 -080030 Android's audio Hardware Abstraction Layer (HAL) connects the higher-level, audio-specific
Heidi von Markham1e7b8b72015-03-09 10:13:48 -070031 framework APIs in <a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a> to the underlying audio driver and hardware. This section includes implementation instructions and tips for improving performance.</p>
Robert Ly35f2fda2013-01-29 16:27:05 -080032</p>
Heidi von Markham1e7b8b72015-03-09 10:13:48 -070033<h2 id="Architecture">Audio Architecture</h2>
Robert Ly35f2fda2013-01-29 16:27:05 -080034<p>
35 The following figure and list describe how audio functionality is implemented and the relevant
36 source code that is involved in the implementation:
37</p>
Heidi von Markham1e7b8b72015-03-09 10:13:48 -070038 <img src="images/ape_fwk_audio.png" alt="Audio architecture" id="figure1" />
Clay Murphy1b77cc22014-12-17 18:20:06 -080039<p class="img-caption">
40 <strong>Figure 1.</strong> Android audio architecture
Robert Ly35f2fda2013-01-29 16:27:05 -080041</p>
42<dl>
43 <dt>
44 Application framework
45 </dt>
46 <dd>
47 At the application framework level is the app code, which utilizes the
48 <a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a>
49 APIs to interact with the audio hardware. Internally, this code calls corresponding JNI glue
Clay Murphyc28f2372013-09-25 16:13:40 -070050 classes to access the native code that interacts with the audio hardware.
Robert Ly35f2fda2013-01-29 16:27:05 -080051 </dd>
52 <dt>
53 JNI
54 </dt>
55 <dd>
56 The JNI code associated with <a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a> is located in the
57 <code>frameworks/base/core/jni/</code> and <code>frameworks/base/media/jni</code> directories.
58 This code calls the lower level native code to obtain access to the audio hardware.
59 </dd>
60 <dt>
61 Native framework
62 </dt>
63 <dd>
64 The native framework is defined in <code>frameworks/av/media/libmedia</code> and provides a
65 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
66 IPC proxies to obtain access to audio-specific services of the media server.
67 </dd>
68 <dt>
69 Binder IPC
70 </dt>
71 <dd>
72 The Binder IPC proxies facilitate communication over process boundaries. They are located in
73 the <code>frameworks/av/media/libmedia</code> directory and begin with the letter "I".
74 </dd>
75 <dt>
76 Media Server
77 </dt>
78 <dd>
79 The audio services in the media server, located in
80 <code>frameworks/av/services/audioflinger</code>, is the actual code that interacts with your
81 HAL implementations.
82 </dd>
83 <dt>
84 HAL
85 </dt>
86 <dd>
Clay Murphyc28f2372013-09-25 16:13:40 -070087 The HAL defines the standard interface that audio services call into
Robert Ly35f2fda2013-01-29 16:27:05 -080088 and that you must implement to have your audio hardware function correctly. The audio HAL
Clay Murphyc28f2372013-09-25 16:13:40 -070089 interfaces are located in
90<code>hardware/libhardware/include/hardware</code>. See <a
Glenn Kastenff257d42014-11-10 16:29:03 -080091href="{@docRoot}devices/halref/audio_8h_source.html">&lt;hardware/audio.h&gt;</a> for additional details.
Robert Ly35f2fda2013-01-29 16:27:05 -080092 </dd>
93 <dt>
94 Kernel Driver
95 </dt>
96 <dd>
97 The audio driver interacts with the hardware and your implementation of the HAL. You can choose
98 to use ALSA, OSS, or a custom driver of your own at this level. The HAL is driver-agnostic.
99 <p>
100 <strong>Note:</strong> If you do choose ALSA, we recommend using <code>external/tinyalsa</code>
101 for the user portion of the driver because of its compatible licensing (The standard user-mode
102 library is GPL licensed).
103</p>
104 </dd>
105</dl>
Glenn Kastenff257d42014-11-10 16:29:03 -0800106<p>
107Not shown: Android native audio based on OpenSL ES.
108This API is exposed as part of
109<a href="https://developer.android.com/tools/sdk/ndk/index.html">Android NDK</a>,
110and is at the same architecture level as
111<a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a>.
Heidi von Markham1e7b8b72015-03-09 10:13:48 -0700112</p>