blob: f9539a9e48f5c74f43a2f6d58d3db0b9854052db [file] [log] [blame]
Heidi von Markhamd0333d62016-07-08 12:05:46 -07001page.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
22configuration</a>, you must package the HAL implementation into a shared library
23and copy it to the appropriate location:</p>
24
25<ol>
26<li>Create a <code>device/&lt;company&gt;/&lt;device&gt;/audio</code>
27directory to contain your library's source files.</li>
28<li>Create an <code>Android.mk</code> file to build the shared library. Ensure
29the Makefile contains the following line:
30<br>
31<pre>
32LOCAL_MODULE := audio.primary.&lt;device&gt;
33</pre>
34<br>
35<p>Your library must be named <code>audio.primary.&lt;device&gt;.so</code>
36so Android can correctly load the library. The <code>primary</code> portion of
37this filename indicates that this shared library is for the primary audio
38hardware located on the device. The module names
39<code>audio.a2dp.&lt;device&gt;</code> and
40<code>audio.usb.&lt;device&gt;</code> are also available for Bluetooth and
41USB audio interfaces. Here is an example of an <code>Android.mk</code> from the
42Galaxy Nexus audio hardware:</p>
43<p><pre>
44LOCAL_PATH := $(call my-dir)
45
46include $(CLEAR_VARS)
47
48LOCAL_MODULE := audio.primary.tuna
49LOCAL_MODULE_RELATIVE_PATH := hw
50LOCAL_SRC_FILES := audio_hw.c ril_interface.c
51LOCAL_C_INCLUDES += \
52 external/tinyalsa/include \
53 $(call include-path-for, audio-utils) \
54 $(call include-path-for, audio-effects)
55LOCAL_SHARED_LIBRARIES := liblog libcutils libtinyalsa libaudioutils libdl
56LOCAL_MODULE_TAGS := optional
57
58include $(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,
63copy the corresponding XML feature file into your product. For example, in your
64product's <code>device/&lt;company&gt;/&lt;device&gt;/device.mk</code>
65Makefile:
66<p><pre>
67PRODUCT_COPY_FILES := ...
68
69PRODUCT_COPY_FILES += \
70frameworks/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/&lt;company&gt;/&lt;device&gt;/device.mk</code> Makefile.
77For example:
78<p><pre>
79PRODUCT_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
85product in the product's
86<code>device/&lt;company&gt;/&lt;device&gt;/device.mk</code> Makefile.
87For example, the Galaxy Nexus requires the primary and Bluetooth audio HAL
88modules:
89<pre>
90PRODUCT_PACKAGES += \
91 audio.primary.tuna \
92 audio.a2dp.default
93</pre>
94</li>
95</ol>