跟着上篇提到的https://obsproject.com/docs/文档看一遍第一章OBS Studio Backend Design能对整个项目的总体框架有个印象了。
对主要的入口函数run_program注释如下:
static const char *run_program_init = "run_program_init";
static int run_program(fstream &logFile, int argc, char *argv[])
{
int ret = -1;
//这个是一个队列,暂时不知道干嘛的,搞的复杂些为了自动释放
auto profilerNameStore = CreateNameStore();
//这是实现退出函数时执行全局profiler释放操作
//这个profiler模块是一个记录执行过程信息的模块,例如记录各种操作耗时等
//,最后释放时会打印这些信息
std::unique_ptr<void, decltype(ProfilerFree)>
prof_release(static_cast<void*>(&ProfilerFree),
ProfilerFree);
profiler_start();
profile_register_root(run_program_init, 0);
//像是一个局部的profiler,构造函数里面记录了开始时间,可能会跟全局的进行
//交互?现看到是析构时将信息写入全局profiler
ScopeProfiler prof{run_program_init};
//qt的api,作用如函数名
QCoreApplication::addLibraryPath(".");
//派生自QApplication,是qt的UI启动类
OBSApp program(argc, argv, profilerNameStore.get());
try {
bool created_log = false;
//初始化一些跟全局配置,语言,用到的目录,主题等
program.AppInit();