105 lines
3.6 KiB
HTML
105 lines
3.6 KiB
HTML
<html devsite>
|
|
<head>
|
|
<title>Configuring a Shared Library</title>
|
|
<meta name="project_path" value="/_project.yaml" />
|
|
<meta name="book_path" value="/_book.yaml" />
|
|
</head>
|
|
<body>
|
|
<!--
|
|
Copyright 2017 The Android Open Source Project
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
you may not use this file except in compliance with the License.
|
|
You may obtain a copy of the License at
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
See the License for the specific language governing permissions and
|
|
limitations under the License.
|
|
-->
|
|
|
|
|
|
|
|
<p>After creating an
|
|
<a href="/devices/audio/implement-policy.html">audio policy
|
|
configuration</a>, you must package the HAL implementation into a shared library
|
|
and copy it to the appropriate location:</p>
|
|
|
|
<ol>
|
|
<li>Create a <code>device/<company>/<device>/audio</code>
|
|
directory to contain your library's source files.</li>
|
|
<li>Create an <code>Android.mk</code> file to build the shared library. Ensure
|
|
the Makefile contains the following line:
|
|
<br>
|
|
<pre class="devsite-click-to-copy">
|
|
LOCAL_MODULE := audio.primary.<device>
|
|
</pre>
|
|
<br>
|
|
<p>Your library must be named <code>audio.primary.<device>.so</code>
|
|
so Android can correctly load the library. The <code>primary</code> portion of
|
|
this filename indicates that this shared library is for the primary audio
|
|
hardware located on the device. The module names
|
|
<code>audio.a2dp.<device></code> and
|
|
<code>audio.usb.<device></code> are also available for Bluetooth and
|
|
USB audio interfaces. Here is an example of an <code>Android.mk</code> from the
|
|
Galaxy Nexus audio hardware:</p>
|
|
|
|
<pre class="devsite-click-to-copy">
|
|
LOCAL_PATH := $(call my-dir)
|
|
|
|
include $(CLEAR_VARS)
|
|
|
|
LOCAL_MODULE := audio.primary.tuna
|
|
LOCAL_MODULE_RELATIVE_PATH := hw
|
|
LOCAL_SRC_FILES := audio_hw.c ril_interface.c
|
|
LOCAL_C_INCLUDES += \
|
|
external/tinyalsa/include \
|
|
$(call include-path-for, audio-utils) \
|
|
$(call include-path-for, audio-effects)
|
|
LOCAL_SHARED_LIBRARIES := liblog libcutils libtinyalsa libaudioutils libdl
|
|
LOCAL_MODULE_TAGS := optional
|
|
|
|
include $(BUILD_SHARED_LIBRARY)
|
|
</pre>
|
|
</li>
|
|
<br>
|
|
<li>If your product supports low latency audio as specified by the Android CDD,
|
|
copy the corresponding XML feature file into your product. For example, in your
|
|
product's <code>device/<company>/<device>/device.mk</code>
|
|
Makefile:
|
|
<pre class="devsite-click-to-copy">
|
|
PRODUCT_COPY_FILES := ...
|
|
|
|
PRODUCT_COPY_FILES += \
|
|
frameworks/native/data/etc/android.hardware.audio.low_latency.xml:system/etc/permissions/android.hardware.audio.low_latency.xml \
|
|
</pre>
|
|
</li>
|
|
<br>
|
|
<li>Copy the audio policy configuration file you created earlier to the
|
|
<code>system/etc/</code> directory in your product's
|
|
<code>device/<company>/<device>/device.mk</code> Makefile.
|
|
For example:
|
|
<pre class="devsite-click-to-copy">
|
|
PRODUCT_COPY_FILES += \
|
|
device/samsung/tuna/audio/audio_policy.conf:system/etc/audio_policy.conf
|
|
</pre>
|
|
</li>
|
|
<br>
|
|
<li>Declare the shared modules of your audio HAL that are required by your
|
|
product in the product's
|
|
<code>device/<company>/<device>/device.mk</code> Makefile.
|
|
For example, the Galaxy Nexus requires the primary and Bluetooth audio HAL
|
|
modules:
|
|
<pre class="devsite-click-to-copy">
|
|
PRODUCT_PACKAGES += \
|
|
audio.primary.tuna \
|
|
audio.a2dp.default
|
|
</pre>
|
|
</li>
|
|
</ol>
|
|
|
|
</body>
|
|
</html>
|