Mercurial > hg > piper-cpp
diff 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 |
line wrap: on
line diff
--- a/capnproto/VampnProto.h Fri Sep 16 16:34:00 2016 +0100 +++ b/capnproto/VampnProto.h Mon Sep 19 13:35:56 2016 +0100 @@ -572,8 +572,10 @@ static void buildConfigurationResponse(ConfigurationResponse::Builder &b, - const Vamp::HostExt::ConfigurationResponse &cr) { + const Vamp::HostExt::ConfigurationResponse &cr, + const PluginHandleMapper &pmapper) { + b.setPluginHandle(pmapper.pluginToHandle(cr.plugin)); auto olist = b.initOutputs(cr.outputs.size()); for (size_t i = 0; i < cr.outputs.size(); ++i) { auto od = olist[i]; @@ -583,8 +585,10 @@ static void readConfigurationResponse(Vamp::HostExt::ConfigurationResponse &cr, - const ConfigurationResponse::Reader &r) { + const ConfigurationResponse::Reader &r, + const PluginHandleMapper &pmapper) { + cr.plugin = pmapper.handleToPlugin(r.getPluginHandle()); cr.outputs.clear(); auto oo = r.getOutputs(); for (const auto &o: oo) { @@ -717,11 +721,12 @@ static void buildVampResponse_Configure(VampResponse::Builder &b, - const Vamp::HostExt::ConfigurationResponse &cr) { + const Vamp::HostExt::ConfigurationResponse &cr, + const PluginHandleMapper &pmapper) { b.setSuccess(!cr.outputs.empty()); b.setErrorText(""); auto u = b.getResponse().initConfigure(); - buildConfigurationResponse(u, cr); + buildConfigurationResponse(u, cr, pmapper); } static void @@ -744,11 +749,11 @@ static void buildVampRequest_Finish(VampRequest::Builder &b, - Vamp::Plugin *p, + const Vamp::HostExt::FinishRequest &req, const PluginHandleMapper &pmapper) { auto u = b.getRequest().initFinish(); - u.setPluginHandle(pmapper.pluginToHandle(p)); + u.setPluginHandle(pmapper.pluginToHandle(req.plugin)); } static void @@ -889,13 +894,16 @@ static void readVampResponse_Configure(Vamp::HostExt::ConfigurationResponse &resp, - const VampResponse::Reader &r) { + const VampResponse::Reader &r, + const PluginHandleMapper &pmapper) { if (getRequestResponseType(r) != RRType::Configure) { throw std::logic_error("not a configuration response"); } resp = {}; if (r.getSuccess()) { - readConfigurationResponse(resp, r.getResponse().getConfigure()); + readConfigurationResponse(resp, + r.getResponse().getConfigure(), + pmapper); } } @@ -923,13 +931,13 @@ } static void - readVampRequest_Finish(Vamp::Plugin *&finishPlugin, + readVampRequest_Finish(Vamp::HostExt::FinishRequest &req, const VampRequest::Reader &r, const PluginHandleMapper &pmapper) { if (getRequestResponseType(r) != RRType::Finish) { throw std::logic_error("not a finish request"); } - finishPlugin = pmapper.handleToPlugin + req.plugin = pmapper.handleToPlugin (r.getRequest().getFinish().getPluginHandle()); }