Mercurial > hg > piper-cpp
comparison capnproto/VampnProto.h @ 55:38780f15ac8d
Make RequestResponse types more consistent by adding plugin to ConfigurationResponse and introducing a FinishRequest
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Mon, 19 Sep 2016 13:35:56 +0100 |
parents | e90fd30990eb |
children | 815e94fedc1c |
comparison
equal
deleted
inserted
replaced
54:524a6d5ee813 | 55:38780f15ac8d |
---|---|
570 readPluginConfiguration(cr.configuration, c); | 570 readPluginConfiguration(cr.configuration, c); |
571 } | 571 } |
572 | 572 |
573 static void | 573 static void |
574 buildConfigurationResponse(ConfigurationResponse::Builder &b, | 574 buildConfigurationResponse(ConfigurationResponse::Builder &b, |
575 const Vamp::HostExt::ConfigurationResponse &cr) { | 575 const Vamp::HostExt::ConfigurationResponse &cr, |
576 | 576 const PluginHandleMapper &pmapper) { |
577 | |
578 b.setPluginHandle(pmapper.pluginToHandle(cr.plugin)); | |
577 auto olist = b.initOutputs(cr.outputs.size()); | 579 auto olist = b.initOutputs(cr.outputs.size()); |
578 for (size_t i = 0; i < cr.outputs.size(); ++i) { | 580 for (size_t i = 0; i < cr.outputs.size(); ++i) { |
579 auto od = olist[i]; | 581 auto od = olist[i]; |
580 buildOutputDescriptor(od, cr.outputs[i]); | 582 buildOutputDescriptor(od, cr.outputs[i]); |
581 } | 583 } |
582 } | 584 } |
583 | 585 |
584 static void | 586 static void |
585 readConfigurationResponse(Vamp::HostExt::ConfigurationResponse &cr, | 587 readConfigurationResponse(Vamp::HostExt::ConfigurationResponse &cr, |
586 const ConfigurationResponse::Reader &r) { | 588 const ConfigurationResponse::Reader &r, |
587 | 589 const PluginHandleMapper &pmapper) { |
590 | |
591 cr.plugin = pmapper.handleToPlugin(r.getPluginHandle()); | |
588 cr.outputs.clear(); | 592 cr.outputs.clear(); |
589 auto oo = r.getOutputs(); | 593 auto oo = r.getOutputs(); |
590 for (const auto &o: oo) { | 594 for (const auto &o: oo) { |
591 Vamp::Plugin::OutputDescriptor desc; | 595 Vamp::Plugin::OutputDescriptor desc; |
592 readOutputDescriptor(desc, o); | 596 readOutputDescriptor(desc, o); |
715 buildConfigurationRequest(u, cr, pmapper); | 719 buildConfigurationRequest(u, cr, pmapper); |
716 } | 720 } |
717 | 721 |
718 static void | 722 static void |
719 buildVampResponse_Configure(VampResponse::Builder &b, | 723 buildVampResponse_Configure(VampResponse::Builder &b, |
720 const Vamp::HostExt::ConfigurationResponse &cr) { | 724 const Vamp::HostExt::ConfigurationResponse &cr, |
725 const PluginHandleMapper &pmapper) { | |
721 b.setSuccess(!cr.outputs.empty()); | 726 b.setSuccess(!cr.outputs.empty()); |
722 b.setErrorText(""); | 727 b.setErrorText(""); |
723 auto u = b.getResponse().initConfigure(); | 728 auto u = b.getResponse().initConfigure(); |
724 buildConfigurationResponse(u, cr); | 729 buildConfigurationResponse(u, cr, pmapper); |
725 } | 730 } |
726 | 731 |
727 static void | 732 static void |
728 buildVampRequest_Process(VampRequest::Builder &b, | 733 buildVampRequest_Process(VampRequest::Builder &b, |
729 const Vamp::HostExt::ProcessRequest &pr, | 734 const Vamp::HostExt::ProcessRequest &pr, |
742 buildProcessResponse(u, pr, pmapper); | 747 buildProcessResponse(u, pr, pmapper); |
743 } | 748 } |
744 | 749 |
745 static void | 750 static void |
746 buildVampRequest_Finish(VampRequest::Builder &b, | 751 buildVampRequest_Finish(VampRequest::Builder &b, |
747 Vamp::Plugin *p, | 752 const Vamp::HostExt::FinishRequest &req, |
748 const PluginHandleMapper &pmapper) { | 753 const PluginHandleMapper &pmapper) { |
749 | 754 |
750 auto u = b.getRequest().initFinish(); | 755 auto u = b.getRequest().initFinish(); |
751 u.setPluginHandle(pmapper.pluginToHandle(p)); | 756 u.setPluginHandle(pmapper.pluginToHandle(req.plugin)); |
752 } | 757 } |
753 | 758 |
754 static void | 759 static void |
755 buildVampResponse_Finish(VampResponse::Builder &b, | 760 buildVampResponse_Finish(VampResponse::Builder &b, |
756 const Vamp::HostExt::ProcessResponse &pr, | 761 const Vamp::HostExt::ProcessResponse &pr, |
887 readConfigurationRequest(req, r.getRequest().getConfigure(), pmapper); | 892 readConfigurationRequest(req, r.getRequest().getConfigure(), pmapper); |
888 } | 893 } |
889 | 894 |
890 static void | 895 static void |
891 readVampResponse_Configure(Vamp::HostExt::ConfigurationResponse &resp, | 896 readVampResponse_Configure(Vamp::HostExt::ConfigurationResponse &resp, |
892 const VampResponse::Reader &r) { | 897 const VampResponse::Reader &r, |
898 const PluginHandleMapper &pmapper) { | |
893 if (getRequestResponseType(r) != RRType::Configure) { | 899 if (getRequestResponseType(r) != RRType::Configure) { |
894 throw std::logic_error("not a configuration response"); | 900 throw std::logic_error("not a configuration response"); |
895 } | 901 } |
896 resp = {}; | 902 resp = {}; |
897 if (r.getSuccess()) { | 903 if (r.getSuccess()) { |
898 readConfigurationResponse(resp, r.getResponse().getConfigure()); | 904 readConfigurationResponse(resp, |
905 r.getResponse().getConfigure(), | |
906 pmapper); | |
899 } | 907 } |
900 } | 908 } |
901 | 909 |
902 static void | 910 static void |
903 readVampRequest_Process(Vamp::HostExt::ProcessRequest &req, | 911 readVampRequest_Process(Vamp::HostExt::ProcessRequest &req, |
921 readProcessResponse(resp, r.getResponse().getProcess(), pmapper); | 929 readProcessResponse(resp, r.getResponse().getProcess(), pmapper); |
922 } | 930 } |
923 } | 931 } |
924 | 932 |
925 static void | 933 static void |
926 readVampRequest_Finish(Vamp::Plugin *&finishPlugin, | 934 readVampRequest_Finish(Vamp::HostExt::FinishRequest &req, |
927 const VampRequest::Reader &r, | 935 const VampRequest::Reader &r, |
928 const PluginHandleMapper &pmapper) { | 936 const PluginHandleMapper &pmapper) { |
929 if (getRequestResponseType(r) != RRType::Finish) { | 937 if (getRequestResponseType(r) != RRType::Finish) { |
930 throw std::logic_error("not a finish request"); | 938 throw std::logic_error("not a finish request"); |
931 } | 939 } |
932 finishPlugin = pmapper.handleToPlugin | 940 req.plugin = pmapper.handleToPlugin |
933 (r.getRequest().getFinish().getPluginHandle()); | 941 (r.getRequest().getFinish().getPluginHandle()); |
934 } | 942 } |
935 | 943 |
936 static void | 944 static void |
937 readVampResponse_Finish(Vamp::HostExt::ProcessResponse &resp, | 945 readVampResponse_Finish(Vamp::HostExt::ProcessResponse &resp, |