Home | History | Annotate | Download | only in audio
      1 page.title=Audio
      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 
     20 <img style="float: right; margin: 0px 15px 15px 15px;"
     21 src="images/ape_fwk_hal_audio.png" alt="Android Audio HAL icon"/>
     22 
     23 <p>
     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.
     28 </p>
     29 
     30 <h2 id="Architecture">Audio Architecture</h2>
     31 <p>
     32 Android audio architecture defines how audio functionality is implemented and
     33 points to the relevant source code involved in the implementation.
     34 </p>
     35 
     36 <img src="images/ape_fwk_audio.png" alt="Audio architecture" id="figure1" />
     37 
     38 <p class="img-caption">
     39 <strong>Figure 1.</strong> Android audio architecture
     40 </p>
     41 
     42 <dl>
     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>
    116 This API is exposed as part of
    117 <a href="https://developer.android.com/tools/sdk/ndk/index.html">Android NDK</a>
    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>.
    120 </dd>
    121 
    122 </dl>
    123