1 <html devsite> 2 <head> 3 <title>Configuring a Shared Library</title> 4 <meta name="project_path" value="/_project.yaml" /> 5 <meta name="book_path" value="/_book.yaml" /> 6 </head> 7 <body> 8 <!-- 9 Copyright 2017 The Android Open Source Project 10 11 Licensed under the Apache License, Version 2.0 (the "License"); 12 you may not use this file except in compliance with the License. 13 You may obtain a copy of the License at 14 15 http://www.apache.org/licenses/LICENSE-2.0 16 17 Unless required by applicable law or agreed to in writing, software 18 distributed under the License is distributed on an "AS IS" BASIS, 19 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 20 See the License for the specific language governing permissions and 21 limitations under the License. 22 --> 23 24 25 26 <p>After creating an 27 <a href="/devices/audio/implement-policy.html">audio policy 28 configuration</a>, you must package the HAL implementation into a shared library 29 and copy it to the appropriate location:</p> 30 31 <ol> 32 <li>Create a <code>device/<company>/<device>/audio</code> 33 directory to contain your library's source files.</li> 34 <li>Create an <code>Android.mk</code> file to build the shared library. Ensure 35 the Makefile contains the following line: 36 <br> 37 <pre class="devsite-click-to-copy"> 38 LOCAL_MODULE := audio.primary.<device> 39 </pre> 40 <br> 41 <p>Your library must be named <code>audio.primary.<device>.so</code> 42 so Android can correctly load the library. The <code>primary</code> portion of 43 this filename indicates that this shared library is for the primary audio 44 hardware located on the device. The module names 45 <code>audio.a2dp.<device></code> and 46 <code>audio.usb.<device></code> are also available for Bluetooth and 47 USB audio interfaces. Here is an example of an <code>Android.mk</code> from the 48 Galaxy Nexus audio hardware:</p> 49 50 <pre class="devsite-click-to-copy"> 51 LOCAL_PATH := $(call my-dir) 52 53 include $(CLEAR_VARS) 54 55 LOCAL_MODULE := audio.primary.tuna 56 LOCAL_MODULE_RELATIVE_PATH := hw 57 LOCAL_SRC_FILES := audio_hw.c ril_interface.c 58 LOCAL_C_INCLUDES += \ 59 external/tinyalsa/include \ 60 $(call include-path-for, audio-utils) \ 61 $(call include-path-for, audio-effects) 62 LOCAL_SHARED_LIBRARIES := liblog libcutils libtinyalsa libaudioutils libdl 63 LOCAL_MODULE_TAGS := optional 64 65 include $(BUILD_SHARED_LIBRARY) 66 </pre> 67 </li> 68 <br> 69 <li>If your product supports low latency audio as specified by the Android CDD, 70 copy the corresponding XML feature file into your product. For example, in your 71 product's <code>device/<company>/<device>/device.mk</code> 72 Makefile: 73 <pre class="devsite-click-to-copy"> 74 PRODUCT_COPY_FILES := ... 75 76 PRODUCT_COPY_FILES += \ 77 frameworks/native/data/etc/android.hardware.audio.low_latency.xml:system/etc/permissions/android.hardware.audio.low_latency.xml \ 78 </pre> 79 </li> 80 <br> 81 <li>Copy the audio policy configuration file you created earlier to the 82 <code>system/etc/</code> directory in your product's 83 <code>device/<company>/<device>/device.mk</code> Makefile. 84 For example: 85 <pre class="devsite-click-to-copy"> 86 PRODUCT_COPY_FILES += \ 87 device/samsung/tuna/audio/audio_policy.conf:system/etc/audio_policy.conf 88 </pre> 89 </li> 90 <br> 91 <li>Declare the shared modules of your audio HAL that are required by your 92 product in the product's 93 <code>device/<company>/<device>/device.mk</code> Makefile. 94 For example, the Galaxy Nexus requires the primary and Bluetooth audio HAL 95 modules: 96 <pre class="devsite-click-to-copy"> 97 PRODUCT_PACKAGES += \ 98 audio.primary.tuna \ 99 audio.a2dp.default 100 </pre> 101 </li> 102 </ol> 103 104 </body> 105 </html> 106