Mercurial > hg > piper-cpp
comparison capnproto/VampnProto.h @ 52:e90fd30990eb
Error handling, and pass plugin handles through
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Fri, 16 Sep 2016 16:20:05 +0100 |
parents | f4244a2d55ac |
children | 38780f15ac8d |
comparison
equal
deleted
inserted
replaced
51:f4244a2d55ac | 52:e90fd30990eb |
---|---|
652 static void | 652 static void |
653 buildProcessResponse(ProcessResponse::Builder &b, | 653 buildProcessResponse(ProcessResponse::Builder &b, |
654 const Vamp::HostExt::ProcessResponse &pr, | 654 const Vamp::HostExt::ProcessResponse &pr, |
655 const PluginHandleMapper &pmapper) { | 655 const PluginHandleMapper &pmapper) { |
656 | 656 |
657 b.setPluginHandle(pmapper.pluginToHandle(pr.plugin)); | |
657 auto f = b.initFeatures(); | 658 auto f = b.initFeatures(); |
658 buildFeatureSet(f, pr.features, | 659 buildFeatureSet(f, pr.features, |
659 pmapper.pluginToOutputIdMapper(pr.plugin)); | 660 pmapper.pluginToOutputIdMapper(pr.plugin)); |
660 } | 661 } |
661 | 662 |
662 static void | 663 static void |
663 readProcessResponse(Vamp::HostExt::ProcessResponse &pr, | 664 readProcessResponse(Vamp::HostExt::ProcessResponse &pr, |
664 const ProcessResponse::Reader &r, | 665 const ProcessResponse::Reader &r, |
665 const PluginHandleMapper &pmapper) { | 666 const PluginHandleMapper &pmapper) { |
666 | 667 |
668 auto h = r.getPluginHandle(); | |
669 pr.plugin = pmapper.handleToPlugin(h); | |
667 readFeatureSet(pr.features, r.getFeatures(), | 670 readFeatureSet(pr.features, r.getFeatures(), |
668 pmapper.handleToOutputIdMapper(r.getPluginHandle())); | 671 pmapper.handleToOutputIdMapper(r.getPluginHandle())); |
669 } | 672 } |
670 | 673 |
671 static void | 674 static void |
754 const PluginHandleMapper &pmapper) { | 757 const PluginHandleMapper &pmapper) { |
755 | 758 |
756 buildVampResponse_Process(b, pr, pmapper); | 759 buildVampResponse_Process(b, pr, pmapper); |
757 } | 760 } |
758 | 761 |
762 static void | |
763 buildVampResponse_Error(VampResponse::Builder &b, | |
764 const std::string &errorText, | |
765 RRType responseType) | |
766 { | |
767 std::string type; | |
768 | |
769 if (responseType == RRType::List) { | |
770 type = "list"; | |
771 b.getResponse().initList(); | |
772 } else if (responseType == RRType::Load) { | |
773 type = "load"; | |
774 b.getResponse().initLoad(); | |
775 } else if (responseType == RRType::Configure) { | |
776 type = "configure"; | |
777 b.getResponse().initConfigure(); | |
778 } else if (responseType == RRType::Process) { | |
779 type = "process"; | |
780 b.getResponse().initProcess(); | |
781 } else if (responseType == RRType::Finish) { | |
782 type = "finish"; | |
783 b.getResponse().initFinish(); | |
784 } else { | |
785 type = "invalid"; | |
786 } | |
787 | |
788 b.setSuccess(false); | |
789 b.setErrorText(std::string("error in ") + type + " request: " + errorText); | |
790 } | |
791 | |
792 static void | |
793 buildVampResponse_Exception(VampResponse::Builder &b, | |
794 const std::exception &e, | |
795 RRType responseType) | |
796 { | |
797 return buildVampResponse_Error(b, e.what(), responseType); | |
798 } | |
799 | |
759 static RRType | 800 static RRType |
760 getRequestResponseType(const VampRequest::Reader &r) { | 801 getRequestResponseType(const VampRequest::Reader &r) { |
761 switch (r.getRequest().which()) { | 802 switch (r.getRequest().which()) { |
762 case VampRequest::Request::Which::LIST: | 803 case VampRequest::Request::Which::LIST: |
763 return RRType::List; | 804 return RRType::List; |