MCPcopy Create free account
hub / github.com/apohl79/audiogridder / loadConfig

Method loadConfig

Server/Source/Server.cpp:68–164  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

66}
67
68void Server::loadConfig() {
69 traceScope();
70 auto file = Defaults::getConfigFileName(Defaults::ConfigServer, {{"id", String(getId())}});
71
72 bool loadUuid = true;
73
74#ifndef AG_UNIT_TESTS
75 // If a server with a new ID is started and has no config yet, fallback to the default config
76 if (!File(file).exists()) {
77 file = Defaults::getConfigFileName(Defaults::ConfigServer, {{"id", "0"}});
78 // But do not inherit the UUID of the default server
79 loadUuid = false;
80 }
81#endif
82
83 logln("loading config from " << file);
84 auto cfg = configParseFile(file);
85 Tracer::setEnabled(jsonGetValue(cfg, "Tracer", Tracer::isEnabled()));
86 Logger::setEnabled(jsonGetValue(cfg, "Logger", Logger::isEnabled()));
87 m_id = jsonGetValue(cfg, "ID", m_id);
88 m_name = jsonGetValue(cfg, "NAME", m_name);
89 if (loadUuid) {
90 m_uuid = jsonGetValue(cfg, "UUID", m_uuid.toDashedString());
91 }
92#ifdef JUCE_MAC
93 m_enableAU = jsonGetValue(cfg, "AU", m_enableAU);
94 logln("AudioUnit support " << (m_enableAU ? "enabled" : "disabled"));
95#endif
96 m_enableVST3 = jsonGetValue(cfg, "VST", m_enableVST3);
97 logln("VST3 support " << (m_enableVST3 ? "enabled" : "disabled"));
98 m_vst3Folders.clear();
99 if (jsonHasValue(cfg, "VST3Folders") && cfg["VST3Folders"].size() > 0) {
100 logln("VST3 custom folders:");
101 for (auto& s : cfg["VST3Folders"]) {
102 if (s.get<std::string>().length() > 0) {
103 logln(" " << s.get<std::string>());
104 m_vst3Folders.add(s.get<std::string>());
105 }
106 }
107 }
108 m_enableVST2 = jsonGetValue(cfg, "VST2", m_enableVST2);
109 logln("VST2 support " << (m_enableVST2 ? "enabled" : "disabled"));
110 m_vst2Folders.clear();
111 if (jsonHasValue(cfg, "VST2Folders") && cfg["VST2Folders"].size() > 0) {
112 logln("VST2 custom folders:");
113 for (auto& s : cfg["VST2Folders"]) {
114 if (s.get<std::string>().length() > 0) {
115 logln(" " << s.get<std::string>());
116 m_vst2Folders.add(s.get<std::string>());
117 }
118 }
119 }
120 m_vstNoStandardFolders = jsonGetValue(cfg, "VSTNoStandardFolders", false);
121 logln("include VST standard folders is " << (m_vstNoStandardFolders ? "disabled" : "enabled"));
122 m_screenCapturingFFmpeg = jsonGetValue(cfg, "ScreenCapturingFFmpeg", m_screenCapturingFFmpeg);
123 String encoder = "webp";
124 m_screenCapturingFFmpegEncMode = ScreenRecorder::WEBP;
125 m_screenCapturingOff = jsonGetValue(cfg, "ScreenCapturingOff", m_screenCapturingOff);

Callers

nothing calls this directly

Calls 11

getConfigFileNameFunction · 0.85
configParseFileFunction · 0.85
jsonGetValueFunction · 0.85
jsonHasValueFunction · 0.85
existsMethod · 0.80
setEnabledFunction · 0.50
isEnabledFunction · 0.50
initializeFunction · 0.50
clearMethod · 0.45
sizeMethod · 0.45
addMethod · 0.45

Tested by

no test coverage detected