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

Method load

Server/Source/ProcessorClient.cpp:353–466  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

351}
352
353bool ProcessorClient::load(const String& settings, const String& layout, uint64 monoChannels, String& err) {
354 traceScope();
355
356 if (!isOk()) {
357 err = "load failed: client not ok";
358 return false;
359 }
360
361 logln("loading " << m_id << "...");
362
363 std::lock_guard<std::mutex> lock(m_cmdMtx);
364
365 TimeStatistic::Timeout timeout(15000);
366 MessageHelper::Error e;
367
368 Message<AddPlugin> msgAddPlugin(this);
369 PLD(msgAddPlugin)
370 .setJson({{"id", m_id.toStdString()},
371 {"settings", settings.toStdString()},
372 {"layout", layout.toStdString()},
373 {"monoChannels", monoChannels}});
374
375 if (msgAddPlugin.send(m_sockCmdOut.get())) {
376 Message<AddPluginResult> msgResult(this);
377 if (!msgResult.read(m_sockCmdOut.get(), &e, timeout.getMillisecondsLeft())) {
378 err = "seems like the plugin did not load or crash: " + e.toString();
379 setAndLogError(err);
380 m_sockCmdOut->close();
381 return false;
382 }
383
384 auto jresult = msgResult.payload.getJson();
385 if (!jresult["success"].get<bool>()) {
386 err = jresult["err"].get<std::string>();
387 setAndLogError("load failed: " + err);
388 m_sockCmdOut->close();
389 return false;
390 }
391
392 if (timeout.getMillisecondsLeft() == 0) {
393 err = "load failed: timeout";
394 setAndLogError(err);
395 m_sockCmdOut->close();
396 return false;
397 }
398
399 logln("reading presets...");
400
401 Message<Presets> msgPresets(this);
402 if (!msgPresets.read(m_sockCmdOut.get(), &e, timeout.getMillisecondsLeft())) {
403 err = "failed to read presets: " + e.toString();
404 setAndLogError(err);
405 m_sockCmdOut->close();
406 return false;
407 }
408 m_presets = StringArray::fromTokens(msgPresets.payload.getString(), "|", "");
409
410 if (timeout.getMillisecondsLeft() == 0) {

Callers

nothing calls this directly

Calls 11

getMillisecondsLeftMethod · 0.80
whatMethod · 0.80
setJsonMethod · 0.45
sendMethod · 0.45
getMethod · 0.45
readMethod · 0.45
toStringMethod · 0.45
closeMethod · 0.45
getJsonMethod · 0.45
getStringMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected