Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 1 | page.title=Audio |
| 2 | @jd:body |
| 3 | |
| 4 | <!-- |
| 5 | Copyright 2010 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 | <div id="qv-wrapper"> |
| 20 | <div id="qv"> |
| 21 | <h2>In this document</h2> |
| 22 | <ol id="auto-toc"> |
| 23 | </ol> |
| 24 | </div> |
| 25 | </div> |
| 26 | |
| 27 | <p> |
Clay Murphy | c28f237 | 2013-09-25 16:13:40 -0700 | [diff] [blame] | 28 | Android's audio Hardware Abstraction Layer (HAL) connects the higher level, audio-specific |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 29 | framework APIs in <a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a> |
| 30 | to the underlying audio driver and hardware. |
| 31 | </p> |
| 32 | |
| 33 | <p> |
| 34 | The following figure and list describe how audio functionality is implemented and the relevant |
| 35 | source code that is involved in the implementation: |
| 36 | </p> |
| 37 | <p> |
| 38 | <img src="images/audio_hal.png"> |
| 39 | </p> |
| 40 | <dl> |
| 41 | <dt> |
| 42 | Application framework |
| 43 | </dt> |
| 44 | <dd> |
| 45 | At the application framework level is the app code, which utilizes the |
| 46 | <a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a> |
| 47 | APIs to interact with the audio hardware. Internally, this code calls corresponding JNI glue |
Clay Murphy | c28f237 | 2013-09-25 16:13:40 -0700 | [diff] [blame] | 48 | classes to access the native code that interacts with the audio hardware. |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 49 | </dd> |
| 50 | <dt> |
| 51 | JNI |
| 52 | </dt> |
| 53 | <dd> |
| 54 | The JNI code associated with <a href="http://developer.android.com/reference/android/media/package-summary.html">android.media</a> is located in the |
| 55 | <code>frameworks/base/core/jni/</code> and <code>frameworks/base/media/jni</code> directories. |
| 56 | This code calls the lower level native code to obtain access to the audio hardware. |
| 57 | </dd> |
| 58 | <dt> |
| 59 | Native framework |
| 60 | </dt> |
| 61 | <dd> |
| 62 | The native framework is defined in <code>frameworks/av/media/libmedia</code> and provides a |
| 63 | 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 |
| 64 | IPC proxies to obtain access to audio-specific services of the media server. |
| 65 | </dd> |
| 66 | <dt> |
| 67 | Binder IPC |
| 68 | </dt> |
| 69 | <dd> |
| 70 | The Binder IPC proxies facilitate communication over process boundaries. They are located in |
| 71 | the <code>frameworks/av/media/libmedia</code> directory and begin with the letter "I". |
| 72 | </dd> |
| 73 | <dt> |
| 74 | Media Server |
| 75 | </dt> |
| 76 | <dd> |
| 77 | The audio services in the media server, located in |
| 78 | <code>frameworks/av/services/audioflinger</code>, is the actual code that interacts with your |
| 79 | HAL implementations. |
| 80 | </dd> |
| 81 | <dt> |
| 82 | HAL |
| 83 | </dt> |
| 84 | <dd> |
Clay Murphy | c28f237 | 2013-09-25 16:13:40 -0700 | [diff] [blame] | 85 | The HAL defines the standard interface that audio services call into |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 86 | and that you must implement to have your audio hardware function correctly. The audio HAL |
Clay Murphy | c28f237 | 2013-09-25 16:13:40 -0700 | [diff] [blame] | 87 | interfaces are located in |
| 88 | <code>hardware/libhardware/include/hardware</code>. See <a |
| 89 | href="http://source.android.com/devices/reference/audio_8h_source.html">audio.h</a> for additional details. |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 90 | </dd> |
| 91 | <dt> |
| 92 | Kernel Driver |
| 93 | </dt> |
| 94 | <dd> |
| 95 | The audio driver interacts with the hardware and your implementation of the HAL. You can choose |
| 96 | to use ALSA, OSS, or a custom driver of your own at this level. The HAL is driver-agnostic. |
| 97 | <p> |
| 98 | <strong>Note:</strong> If you do choose ALSA, we recommend using <code>external/tinyalsa</code> |
| 99 | for the user portion of the driver because of its compatible licensing (The standard user-mode |
| 100 | library is GPL licensed). |
| 101 | </p> |
| 102 | </dd> |
| 103 | </dl> |
Clay Murphy | 47b1d3f | 2013-10-03 10:02:22 -0700 | [diff] [blame^] | 104 | |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 105 | <p> |
Clay Murphy | 47b1d3f | 2013-10-03 10:02:22 -0700 | [diff] [blame^] | 106 | See the rest of the pages within the Audio section for implementation |
| 107 | instructions and ways to improve performance. |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 108 | </p> |