comparison vamp-server/simple-server.cpp @ 293:ae7397deffaa

Improve error handling (i.e. add some) for failure to initialise
author Chris Cannam <cannam@all-day-breakfast.com>
date Wed, 05 Jan 2022 14:02:19 +0000
parents c0b29d2af155
children
comparison
equal deleted inserted replaced
292:16842bf06026 293:ae7397deffaa
459 break; 459 break;
460 460
461 case RRType::Load: 461 case RRType::Load:
462 response.loadResponse = 462 response.loadResponse =
463 LoaderRequests().loadPlugin(request.loadRequest); 463 LoaderRequests().loadPlugin(request.loadRequest);
464 if (response.loadResponse.plugin != nullptr) { 464
465 mapper.addPlugin(response.loadResponse.plugin); 465 if (!response.loadResponse.plugin) {
466 if (debug) { 466 throw runtime_error("unable to load plugin");
467 cerr << "piper-vamp-server " << pid 467 }
468 << ": loaded plugin, handle = " 468
469 << mapper.pluginToHandle(response.loadResponse.plugin) 469 mapper.addPlugin(response.loadResponse.plugin);
470 << endl; 470 if (debug) {
471 } 471 cerr << "piper-vamp-server " << pid
472 response.success = true; 472 << ": loaded plugin, handle = "
473 } 473 << mapper.pluginToHandle(response.loadResponse.plugin)
474 << endl;
475 }
476 response.success = true;
474 break; 477 break;
475 478
476 case RRType::Configure: 479 case RRType::Configure:
477 { 480 {
478 auto &creq = request.configurationRequest; 481 auto &creq = request.configurationRequest;
489 creq.configuration.framing.blockSize == 0) { 492 creq.configuration.framing.blockSize == 0) {
490 throw runtime_error("step and block size must be non-zero"); 493 throw runtime_error("step and block size must be non-zero");
491 } 494 }
492 495
493 response.configurationResponse = LoaderRequests().configurePlugin(creq); 496 response.configurationResponse = LoaderRequests().configurePlugin(creq);
497
498 if (response.configurationResponse.outputs.empty()) {
499 throw runtime_error("plugin failed to initialise");
500 }
494 501
495 if (!response.configurationResponse.outputs.empty()) { 502 mapper.markConfigured
496 mapper.markConfigured 503 (h,
497 (h, 504 creq.configuration.channelCount,
498 creq.configuration.channelCount, 505 response.configurationResponse.framing.blockSize);
499 response.configurationResponse.framing.blockSize); 506 response.success = true;
500 response.success = true;
501 }
502 break; 507 break;
503 } 508 }
504 509
505 case RRType::Process: 510 case RRType::Process:
506 { 511 {