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

Method startSandbox

Server/Source/ProcessorClient.cpp:120–173  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

118}
119
120bool ProcessorClient::startSandbox() {
121 try {
122 std::lock_guard<std::mutex> lock(m_cmdMtx);
123
124 if (m_process.isRunning()) {
125 logln("killing already running sandbox");
126 m_process.kill();
127 m_process.waitForProcessToFinish(-1);
128 }
129
130 auto cfgDump = m_cfg.toJson().dump();
131 MemoryBlock config(cfgDump.c_str(), cfgDump.size());
132
133 StringArray args;
134
135#ifndef AG_UNIT_TESTS
136 args.add(File::getSpecialLocation(File::currentExecutableFile).getFullPathName());
137 if (auto srv = getApp()->getServer()) {
138 args.addArray({"-id", String(srv->getId())});
139 } else {
140 throw std::runtime_error("no server object");
141 }
142#else
143 auto exe = File::getSpecialLocation(File::currentExecutableFile).getParentDirectory();
144#if JUCE_WINDOWS
145 exe = exe.getChildFile("AudioGridderServer.exe");
146#else
147 exe = exe.getChildFile("AudioGridderServer.app")
148 .getChildFile("Contents")
149 .getChildFile("MacOS")
150 .getChildFile("AudioGridderServer");
151#endif
152 // args.add("lldb");
153 args.add(exe.getFullPathName());
154 // args.addArray({"-o", "process launch --tty", "--"});
155 args.addArray({"-id", "999"});
156#endif
157
158 args.add("-load");
159 args.addArray({"-pluginid", m_id});
160 args.addArray({"-workerport", String(m_port)});
161 args.addArray({"-config", config.toBase64Encoding()});
162
163 logln("starting sandbox process: " << args.joinIntoString(" "));
164
165 return m_process.start(args, 0);
166 } catch (const std::exception& e) {
167 setAndLogError("failed to start sandbox: " + String(e.what()));
168 } catch (...) {
169 setAndLogError("failed to start sandbox: unknown error");
170 }
171
172 return false;
173}
174
175bool ProcessorClient::connectSandbox() {
176 logln("connecting to sandbox at port " << m_port);

Callers

nothing calls this directly

Calls 8

dumpMethod · 0.80
getIdMethod · 0.80
whatMethod · 0.80
toJsonMethod · 0.45
sizeMethod · 0.45
addMethod · 0.45
getServerMethod · 0.45
startMethod · 0.45

Tested by

no test coverage detected