Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 1 | page.title=Audio |
| 2 | @jd:body |
| 3 | |
| 4 | <!-- |
Heidi von Markham | 1e7b8b7 | 2015-03-09 10:13:48 -0700 | [diff] [blame] | 5 | Copyright 2015 The Android Open Source Project |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 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 | --> |
Heidi von Markham | 1e7b8b7 | 2015-03-09 10:13:48 -0700 | [diff] [blame] | 19 | |
Heidi von Markham | 83132e7 | 2015-04-13 17:04:50 -0700 | [diff] [blame] | 20 | <img style="float: right; margin: 0px 15px 15px 15px;" |
| 21 | src="images/ape_fwk_hal_audio.png" alt="Android Audio HAL icon"/> |
| 22 | |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 23 | <p> |
Heidi von Markham | 83132e7 | 2015-04-13 17:04:50 -0700 | [diff] [blame] | 24 | Android's audio Hardware Abstraction Layer (HAL) connects the higher-level, |
| 25 | audio-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 |
| 26 | hardware. This section includes implementation instructions and tips for |
| 27 | improving performance. |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 28 | </p> |
Heidi von Markham | 83132e7 | 2015-04-13 17:04:50 -0700 | [diff] [blame] | 29 | |
Heidi von Markham | 1e7b8b7 | 2015-03-09 10:13:48 -0700 | [diff] [blame] | 30 | <h2 id="Architecture">Audio Architecture</h2> |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 31 | <p> |
Heidi von Markham | 83132e7 | 2015-04-13 17:04:50 -0700 | [diff] [blame] | 32 | Android audio architecture defines how audio functionality is implemented and |
| 33 | points to the relevant source code involved in the implementation. |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 34 | </p> |
Heidi von Markham | 83132e7 | 2015-04-13 17:04:50 -0700 | [diff] [blame] | 35 | |
| 36 | <img src="images/ape_fwk_audio.png" alt="Audio architecture" id="figure1" /> |
| 37 | |
Clay Murphy | 1b77cc2 | 2014-12-17 18:20:06 -0800 | [diff] [blame] | 38 | <p class="img-caption"> |
Heidi von Markham | 83132e7 | 2015-04-13 17:04:50 -0700 | [diff] [blame] | 39 | <strong>Figure 1.</strong> Android audio architecture |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 40 | </p> |
Heidi von Markham | 83132e7 | 2015-04-13 17:04:50 -0700 | [diff] [blame] | 41 | |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 42 | <dl> |
Heidi von Markham | 83132e7 | 2015-04-13 17:04:50 -0700 | [diff] [blame] | 43 | |
| 44 | <dt> |
| 45 | Application framework |
| 46 | </dt> |
| 47 | <dd> |
| 48 | The 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 |
| 49 | interact with audio hardware. Internally, this code calls corresponding JNI glue |
| 50 | classes to access the native code that interacts with audio hardware. |
| 51 | </dd> |
| 52 | |
| 53 | <dt> |
| 54 | JNI |
| 55 | </dt> |
| 56 | <dd> |
| 57 | The 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 |
| 58 | hardware. JNI is located in <code>frameworks/base/core/jni/</code> and |
| 59 | <code>frameworks/base/media/jni</code>. |
| 60 | </dd> |
| 61 | |
| 62 | <dt> |
| 63 | Native framework |
| 64 | </dt> |
| 65 | <dd> |
| 66 | The 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 |
| 67 | Binder IPC proxies to access the audio-specific services of the media server. |
| 68 | Native framework code is located in <code>frameworks/av/media/libmedia</code>. |
| 69 | </dd> |
| 70 | |
| 71 | <dt> |
| 72 | Binder IPC |
| 73 | </dt> |
| 74 | <dd> |
| 75 | Binder IPC proxies facilitate communication over process boundaries. Proxies are |
| 76 | located in <code>frameworks/av/media/libmedia</code> and begin with the letter |
| 77 | "I". |
| 78 | </dd> |
| 79 | |
| 80 | <dt> |
| 81 | Media server |
| 82 | </dt> |
| 83 | <dd> |
| 84 | The media server contains audio services, which are the actual code that |
| 85 | interacts with your HAL implementations. The media server is located in |
| 86 | <code>frameworks/av/services/audioflinger</code>. |
| 87 | </dd> |
| 88 | |
| 89 | <dt> |
| 90 | HAL |
| 91 | </dt> |
| 92 | <dd> |
| 93 | The HAL defines the standard interface that audio services call into and that |
| 94 | you must implement for your audio hardware to function correctly. The audio HAL |
| 95 | interfaces are located in <code>hardware/libhardware/include/hardware</code>. |
| 96 | For details, see <a |
| 97 | href="{@docRoot}devices/halref/audio_8h_source.html">hardware/audio.h</a>. |
| 98 | </dd> |
| 99 | |
| 100 | <dt> |
| 101 | Kernel driver |
| 102 | </dt> |
| 103 | <dd> |
| 104 | The audio driver interacts with your hardware and HAL implementation. You can |
| 105 | use Advanced Linux Sound Architecture (ALSA), Open Sound System (OSS), or a |
| 106 | custom 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 |
| 109 | compatible licensing (the standard user-mode library is GPL-licensed).</p> |
| 110 | </dd> |
| 111 | |
| 112 | <dt> |
| 113 | Android native audio based on Open SL ES <em>(not shown)</em> |
| 114 | </dt> |
| 115 | <dd> |
Glenn Kasten | ff257d4 | 2014-11-10 16:29:03 -0800 | [diff] [blame] | 116 | This API is exposed as part of |
Heidi von Markham | 83132e7 | 2015-04-13 17:04:50 -0700 | [diff] [blame] | 117 | <a href="https://developer.android.com/tools/sdk/ndk/index.html">Android NDK</a> |
Glenn Kasten | ff257d4 | 2014-11-10 16:29:03 -0800 | [diff] [blame] | 118 | and 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 Markham | 83132e7 | 2015-04-13 17:04:50 -0700 | [diff] [blame] | 120 | </dd> |
| 121 | |
Clay Murphy | d6020bf | 2015-07-13 12:09:45 -0700 | [diff] [blame] | 122 | </dl> |