static int run_program(fstream &logFile, int argc, char *argv[])
{
/*初始化和读取profile相关信息*/
int ret = -1;
auto profilerNameStore = CreateNameStore();
std::unique_ptr<void, decltype(ProfilerFree)>
prof_release(static_cast<void*>(&ProfilerFree),
ProfilerFree);
profiler_start();
profile_register_root(run_program_init, 0);
auto PrintInitProfile = [&]()
{
auto snap = GetSnapshot();
profiler_snapshot_filter_roots(snap.get(), [](void *data,
const char *name, bool *remove)
{
*remove = (*static_cast<const char**>(data)) != name;
return true;
}, static_cast<void*>(&run_program_init));
profiler_print(snap.get());
};
ScopeProfiler prof{run_program_init};
QCoreApplication::addLibraryPath(".");
/*生成OBSApp 对象*/
OBSApp program(argc, argv, profilerNameStore.get());
try {
/*初始化应用*/
program.AppInit();
OBSTranslator translator;
create_log_file(logFile);
delete_oldest_file("obs-studio/profiler_data");
program.installTranslator(&translator);
/*初始化obs模块*/
if (!program.OBSInit())
return 0;
prof.Stop();
return program.exec();
} catch (const char *error) {
blog(LOG_ERROR, "%s", error);
OBSErrorBox(nullptr, "%s", error);
}
return ret;
}