1page.title=Audio Implementation 2@jd:body 3 4<!-- 5 Copyright 2015 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>This section explains how to implement the audio Hardware Abstraction Layer 28(HAL), provides details about configuring an audio policy (file formats, code 29organization, pre-processing effects), and describes how to configure the shared 30library (creating the <code>Android.mk</code> file).</p> 31 32<h2 id=implementing>Implementing the audio HAL</h2> 33 34<p>The audio HAL is composed of the following interfaces:</p> 35 36<ul> 37<li><code>hardware/libhardware/include/hardware/audio.h</code>. Represents the 38main functions of an audio device.</li> 39<li><code>hardware/libhardware/include/hardware/audio_effect.h</code>. 40Represents effects that can be applied to audio such as downmixing, echo, or 41noise suppression.</li> 42</ul> 43 44<p>You must implement all interfaces.</p> 45 46<h2 id=headers>Audio header files</h2> 47<p>For a reference of the properties you can define, refer to the audio header 48files:</p> 49 50<ul> 51<li>In Android 6.0 and higher, see 52<code>system/media/audio/include/system/audio.h</code>.</li> 53<li>In Android 5.1 and lower, see 54<code>system/core/include/system/audio.h</code>.</li> 55</ul> 56 57<p>For an example, refer to the implementation for the Galaxy Nexus at 58<code>device/samsung/tuna/audio</code>.</p> 59 60<h2 id=next-steps>Next steps</h2> 61 62<p>In addition to implementing the audio HAL, you must also create an 63<a href="{@docRoot}devices/audio/implement-policy.html">audio policy 64configuration file</a> that describes your audio topology and package the HAL 65implementation into a 66<a href="{@docRoot}devices/audio/implement-shared-library.html">shared 67library</a>. You can also configure 68<a href="{@docRoot}devices/audio/implement-pre-processing.html">pre-processing 69effects</a> such as automatic gain control and noise suppression.</p> 70