Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 1 | page.title=Audio |
| 2 | @jd:body |
| 3 | |
| 4 | <!-- |
Clay Murphy | 768b82a | 2013-11-12 11:32:41 -0800 | [diff] [blame] | 5 | Copyright 2013 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 | --> |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 19 | <p> |
Clay Murphy | c28f237 | 2013-09-25 16:13:40 -0700 | [diff] [blame] | 20 | 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] | 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> |
Glenn Kasten | 3dbc804 | 2014-02-04 09:58:32 -0800 | [diff] [blame] | 30 | <img src="images/audio_hal.png" alt="Audio architecture" /> |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 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 |
Clay Murphy | c28f237 | 2013-09-25 16:13:40 -0700 | [diff] [blame] | 40 | classes to access the native code that interacts with the audio hardware. |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 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> |
Clay Murphy | c28f237 | 2013-09-25 16:13:40 -0700 | [diff] [blame] | 77 | The HAL defines the standard interface that audio services call into |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 78 | 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] | 79 | interfaces are located in |
| 80 | <code>hardware/libhardware/include/hardware</code>. See <a |
Clay Murphy | 28730d1 | 2014-03-24 18:05:16 -0700 | [diff] [blame^] | 81 | href="{@docRoot}devices/halref/audio_8h_source.html">audio.h</a> for additional details. |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 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> |
Clay Murphy | 47b1d3f | 2013-10-03 10:02:22 -0700 | [diff] [blame] | 96 | |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 97 | <p> |
Clay Murphy | 47b1d3f | 2013-10-03 10:02:22 -0700 | [diff] [blame] | 98 | See the rest of the pages within the Audio section for implementation |
| 99 | instructions and ways to improve performance. |
Robert Ly | 35f2fda | 2013-01-29 16:27:05 -0800 | [diff] [blame] | 100 | </p> |