1 page.title=Configuring a Shared Library 2 @jd:body 3 4 <!-- 5 Copyright 2016 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 <p>After creating an 21 <a href="{@docRoot}devices/audio/implement-policy.html">audio policy 22 configuration</a>, you must package the HAL implementation into a shared library 23 and copy it to the appropriate location:</p> 24 25 <ol> 26 <li>Create a <code>device/<company>/<device>/audio</code> 27 directory to contain your library's source files.</li> 28 <li>Create an <code>Android.mk</code> file to build the shared library. Ensure 29 the Makefile contains the following line: 30 <br> 31 <pre> 32 LOCAL_MODULE := audio.primary.<device> 33 </pre> 34 <br> 35 <p>Your library must be named <code>audio.primary.<device>.so</code> 36 so Android can correctly load the library. The <code>primary</code> portion of 37 this filename indicates that this shared library is for the primary audio 38 hardware located on the device. The module names 39 <code>audio.a2dp.<device></code> and 40 <code>audio.usb.<device></code> are also available for Bluetooth and 41 USB audio interfaces. Here is an example of an <code>Android.mk</code> from the 42 Galaxy Nexus audio hardware:</p> 43 <p><pre> 44 LOCAL_PATH := $(call my-dir) 45 46 include $(CLEAR_VARS) 47 48 LOCAL_MODULE := audio.primary.tuna 49 LOCAL_MODULE_RELATIVE_PATH := hw 50 LOCAL_SRC_FILES := audio_hw.c ril_interface.c 51 LOCAL_C_INCLUDES += \ 52 external/tinyalsa/include \ 53 $(call include-path-for, audio-utils) \ 54 $(call include-path-for, audio-effects) 55 LOCAL_SHARED_LIBRARIES := liblog libcutils libtinyalsa libaudioutils libdl 56 LOCAL_MODULE_TAGS := optional 57 58 include $(BUILD_SHARED_LIBRARY) 59 </pre></p> 60 </li> 61 <br> 62 <li>If your product supports low latency audio as specified by the Android CDD, 63 copy the corresponding XML feature file into your product. For example, in your 64 product's <code>device/<company>/<device>/device.mk</code> 65 Makefile: 66 <p><pre> 67 PRODUCT_COPY_FILES := ... 68 69 PRODUCT_COPY_FILES += \ 70 frameworks/native/data/etc/android.hardware.audio.low_latency.xml:system/etc/permissions/android.hardware.audio.low_latency.xml \ 71 </pre></p> 72 </li> 73 <br> 74 <li>Copy the audio policy configuration file you created earlier to the 75 <code>system/etc/</code> directory in your product's 76 <code>device/<company>/<device>/device.mk</code> Makefile. 77 For example: 78 <p><pre> 79 PRODUCT_COPY_FILES += \ 80 device/samsung/tuna/audio/audio_policy.conf:system/etc/audio_policy.conf 81 </pre></p> 82 </li> 83 <br> 84 <li>Declare the shared modules of your audio HAL that are required by your 85 product in the product's 86 <code>device/<company>/<device>/device.mk</code> Makefile. 87 For example, the Galaxy Nexus requires the primary and Bluetooth audio HAL 88 modules: 89 <pre> 90 PRODUCT_PACKAGES += \ 91 audio.primary.tuna \ 92 audio.a2dp.default 93 </pre> 94 </li> 95 </ol> 96