【WIP】aap-core安卓音频插件框架开源项目底层技术研究
https://github.com/atsushieno/aap-core
关于宿主Host加载app插件
- 程序入口:libandroidaudioplugin.so
- 入口函数:GetAndroidAudioPluginFactory
aap::PluginInstance* aap::PluginHost::instantiateLocalPlugin(const PluginInformation *descriptor) { dlerror(); // clean up any previous error state auto file = descriptor->getLocalPluginSharedLibrary(); auto metadataFullPath = descriptor->getMetadataFullPath(); if (!metadataFullPath.empty()) { size_t idx = metadataFullPath.find_last_of('/'); if (idx > 0) { auto soFullPath = metadataFullPath.substr(0, idx + 1) + file; struct stat st; if (stat(soFullPath.c_str(), &st) == 0) file = soFullPath; } } auto entrypoint = descriptor->getLocalPluginLibraryEntryPoint(); auto dl = dlopen(file.length() > 0 ? file.c_str() : "libandroidaudioplugin.so", RTLD_LAZY); if (dl == nullptr) { aap::a_log_f(AAP_LOG_LEVEL_ERROR, LOG_TAG, "aap::PluginHost: AAP library %s could not be loaded: %s", file.c_str(), dlerror()); return nullptr; } auto factoryGetter = (aap_factory_t) dlsym(dl, entrypoint.length() > 0 ? entrypoint.c_str() : "GetAndroidAudioPluginFactory"); if (factoryGetter == nullptr) { aap::a_log_f(AAP_LOG_LEVEL_ERROR, LOG_TAG, "aap::PluginHost: AAP factory entrypoint function %s was not found in %s.", entrypoint.c_str(), file.c_str()); return nullptr; } auto pluginFactory = factoryGetter(); if (pluginFactory == nullptr) { aap::a_log_f(AAP_LOG_LEVEL_ERROR, LOG_TAG, "aap::PluginHost: AAP factory entrypoint function %s could not instantiate a plugin.", entrypoint.c_str()); return nullptr; } auto instance = new LocalPluginInstance(this, aapxs_definition_registry, localInstanceIdSerial++, descriptor, pluginFactory, event_midi2_input_buffer_size); instances.emplace_back(instance); return instance; }
扩展API设计

进程模型

浙公网安备 33010602011771号