AudioFlinger启动过程分析(android_audio)
Posted we1less
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了AudioFlinger启动过程分析(android_audio)相关的知识,希望对你有一定的参考价值。
参考 https://blog.csdn.net/zyuanyun/article/details/60890534#t4
首先来分析一下AudioFlinger
里面存在一个数组mPlaybackThreads里面的每一个线程都对应一个output
1.加载哪个so文件? 文件名是什么? 文件名从何而来?
参考上一篇https://blog.csdn.net/we1less/article/details/118424539
openDevice hardware/interfaces/audio/2.0/default/DevicesFactory.cpp 环节
audio.primary.xxx.so
audio.primary.goldfish.so
2.该so文件由什么源文件组成? (此部分有待验证)
audio.primary.$(TARGET_DEVICE) : device/friendly-arm/common/libaudio/AudioHardware.cpp
libhardware_legacy
libhardware_legacy : hardware/libhardware_legacy/audio/audio_hw_hal.cpp
3.对硬件的封装:
AudioHwDevice frameworks/av/services/audioflinger/AudioHwDevice.cpp
每一个AudioHwDevice对应一个.so动态库所支持的设备
再把这些支持的硬件加入到mAudioHwDevs里面
audio_module_handle_t AudioFlinger::loadHwModule_l(const char *name){
...
sp<DeviceHalInterface> dev;
int rc = mDevicesFactoryHal->openDevice(name, &dev);
...
mAudioHwDevs.add(handle, new AudioHwDevice(handle, name, dev, flags));
}
loadAudioInterface hardware/interfaces/audio/2.0/default/DevicesFactory.cpp
audio_hw_device_t 结构体在
libhardware hardware/libhardware/include/hardware/audio.h
int DevicesFactory::loadAudioInterface(const char *if_name, audio_hw_device_t **dev)
{
const hw_module_t *mod;
int rc;
rc = hw_get_module_by_class(AUDIO_HARDWARE_MODULE_ID, if_name, &mod);
...
rc = audio_hw_device_open(mod, dev);
...
out:
*dev = NULL;
return rc;
}
main frameworks/av/media/audioserver/main_audioserver.cpp
int main(int argc __unused, char **argv)
{
sp<ProcessState> proc(ProcessState::self());
sp<IServiceManager> sm = defaultServiceManager();
ALOGI("ServiceManager: %p", sm.get());
AudioFlinger::instantiate();
AudioPolicyService::instantiate();
ProcessState::self()->startThreadPool();
android::hardware::ProcessState::self()->startThreadPool();
IPCThreadState::self()->joinThreadPool();
}
以上是关于AudioFlinger启动过程分析(android_audio)的主要内容,如果未能解决你的问题,请参考以下文章