•建立一个音频库
•接口
AudioHardwareInterface充当专有音频driver和Android AudioFlinger服务之间的连接体,Audio server的核心即处理来自应用程序的所有音频相关要求。
<!--[if gte vml 1]><v:shapetype id="_x0000_t75" coordsize="21600,21600" o:spt="75" o:preferrelative="t" path="m@4@5l@4@11@9@11@9@5xe" filled="f" stroked="f"> <v:stroke joinstyle="miter" /> <v:formulas> <v:f eqn="if lineDrawn pixelLineWidth 0" /> <v:f eqn="sum @0 1 0" /> <v:f eqn="sum 0 0 @1" /> <v:f eqn="prod @2 1 2" /> <v:f eqn="prod @3 21600 pixelWidth" /> <v:f eqn="prod @3 21600 pixelHeight" /> <v:f eqn="sum @0 0 1" /> <v:f eqn="prod @6 1 2" /> <v:f eqn="prod @7 21600 pixelWidth" /> <v:f eqn="sum @8 21600 0" /> <v:f eqn="prod @7 21600 pixelHeight" /> <v:f eqn="sum @10 21600 0" /> </v:formulas> <v:path o:extrusionok="f" gradientshapeok="t" o:connecttype="rect" /> <o:lock v:ext="edit" aspectratio="t" /> </v:shapetype><v:shape id="_x0000_i1025" type="#_x0000_t75" alt="" style='width:405pt; height:372pt'> <v:imagedata src="file:///C:/DOCUME~1/johndeng/LOCALS~1/Temp/msohtml1/01/clip_image001.gif" mce_src="file:///C:/DOCUME~1/johndeng/LOCALS~1/Temp/msohtml1/01/clip_image001.gif" o:href="http://source.android.com/porting/images/android_audio_architecture.gif" /> </v:shape><![endif]-->
实线表示Android的块元素和虚线代表partner-specific组成部分。
建设一个音频库
为了实现一个音频驱动程序,创建一个共享库,实现了在AudioHardwareInterface.h定义的接口。您必须命名您的共享librarylibaudio.so,以便它会从/system/lib中在运行时加载。放置libaudio来源和Android.mk 在/vendor/acme/chipset_or_board/libaudio/。
下面的Android.mk文件,确保与libaudio编译和链接到相应的库:
LOCAL_PATH := $(call my-dir)
include $(CLEAR_VARS)
LOCAL_MODULE := libaudio
LOCAL_SHARED_LIBRARIES := /
libcutils /
libutils /
libmedia /
libhardware
LOCAL_SRC_FILES += MyAudioHardware.cpp
LOCAL_CFLAGS +=
LOCAL_C_INCLUDES +=
LOCAL_STATIC_LIBRARIES += libaudiointerface
include $(BUILD_SHARED_LIBRARY)