Mercurial > hg > piper-cpp
comparison vamp-capnp/VampnProto.h @ 97:427c4c725085
Bring in the Request/Response classes that were in the Vamp SDK, adding them to vamp-support in here instead
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Thu, 13 Oct 2016 18:05:35 +0100 |
parents | b6ac26b72b59 |
children | cd438188e3f9 |
comparison
equal
deleted
inserted
replaced
96:215c9fb6b7a4 | 97:427c4c725085 |
---|---|
37 #include <capnp/message.h> | 37 #include <capnp/message.h> |
38 //#include <capnp/serialize-packed.h> | 38 //#include <capnp/serialize-packed.h> |
39 | 39 |
40 #include <vamp-hostsdk/Plugin.h> | 40 #include <vamp-hostsdk/Plugin.h> |
41 #include <vamp-hostsdk/PluginLoader.h> | 41 #include <vamp-hostsdk/PluginLoader.h> |
42 #include <vamp-hostsdk/PluginStaticData.h> | 42 |
43 #include <vamp-hostsdk/PluginConfiguration.h> | 43 #include "vamp-support/PluginStaticData.h" |
44 #include <vamp-hostsdk/RequestResponse.h> | 44 #include "vamp-support/PluginConfiguration.h" |
45 #include "vamp-support/RequestResponse.h" | |
45 | 46 |
46 #include "vamp-support/PluginHandleMapper.h" | 47 #include "vamp-support/PluginHandleMapper.h" |
47 #include "vamp-support/PluginOutputIdMapper.h" | 48 #include "vamp-support/PluginOutputIdMapper.h" |
48 #include "vamp-support/RequestResponseType.h" | 49 #include "vamp-support/RequestResponseType.h" |
49 | 50 |
50 namespace piper | 51 namespace piper_vamp |
51 { | 52 { |
52 | 53 |
53 /** | 54 /** |
54 * Convert the structures laid out in the Vamp SDK classes into Cap'n | 55 * Convert the structures laid out in the Vamp SDK classes into Cap'n |
55 * Proto structures (and back again). | 56 * Proto structures (and back again). |
90 static void readValueExtents(T &t, const M &m) { | 91 static void readValueExtents(T &t, const M &m) { |
91 t.minValue = m.getMinValue(); | 92 t.minValue = m.getMinValue(); |
92 t.maxValue = m.getMaxValue(); | 93 t.maxValue = m.getMaxValue(); |
93 } | 94 } |
94 | 95 |
95 static void buildRealTime(RealTime::Builder &b, const Vamp::RealTime &t) { | 96 static void buildRealTime(piper::RealTime::Builder &b, |
97 const Vamp::RealTime &t) { | |
96 b.setSec(t.sec); | 98 b.setSec(t.sec); |
97 b.setNsec(t.nsec); | 99 b.setNsec(t.nsec); |
98 } | 100 } |
99 | 101 |
100 static void readRealTime(Vamp::RealTime &t, const RealTime::Reader &r) { | 102 static void readRealTime(Vamp::RealTime &t, |
103 const piper::RealTime::Reader &r) { | |
101 t.sec = r.getSec(); | 104 t.sec = r.getSec(); |
102 t.nsec = r.getNsec(); | 105 t.nsec = r.getNsec(); |
103 } | 106 } |
104 | 107 |
105 static SampleType | 108 static piper::SampleType |
106 fromSampleType(Vamp::Plugin::OutputDescriptor::SampleType t) { | 109 fromSampleType(Vamp::Plugin::OutputDescriptor::SampleType t) { |
107 switch (t) { | 110 switch (t) { |
108 case Vamp::Plugin::OutputDescriptor::OneSamplePerStep: | 111 case Vamp::Plugin::OutputDescriptor::OneSamplePerStep: |
109 return SampleType::ONE_SAMPLE_PER_STEP; | 112 return piper::SampleType::ONE_SAMPLE_PER_STEP; |
110 case Vamp::Plugin::OutputDescriptor::FixedSampleRate: | 113 case Vamp::Plugin::OutputDescriptor::FixedSampleRate: |
111 return SampleType::FIXED_SAMPLE_RATE; | 114 return piper::SampleType::FIXED_SAMPLE_RATE; |
112 case Vamp::Plugin::OutputDescriptor::VariableSampleRate: | 115 case Vamp::Plugin::OutputDescriptor::VariableSampleRate: |
113 return SampleType::VARIABLE_SAMPLE_RATE; | 116 return piper::SampleType::VARIABLE_SAMPLE_RATE; |
114 } | 117 } |
115 throw std::logic_error("unexpected Vamp SampleType enum value"); | 118 throw std::logic_error("unexpected Vamp SampleType enum value"); |
116 } | 119 } |
117 | 120 |
118 static Vamp::Plugin::OutputDescriptor::SampleType | 121 static Vamp::Plugin::OutputDescriptor::SampleType |
119 toSampleType(SampleType t) { | 122 toSampleType(piper::SampleType t) { |
120 switch (t) { | 123 switch (t) { |
121 case SampleType::ONE_SAMPLE_PER_STEP: | 124 case piper::SampleType::ONE_SAMPLE_PER_STEP: |
122 return Vamp::Plugin::OutputDescriptor::OneSamplePerStep; | 125 return Vamp::Plugin::OutputDescriptor::OneSamplePerStep; |
123 case SampleType::FIXED_SAMPLE_RATE: | 126 case piper::SampleType::FIXED_SAMPLE_RATE: |
124 return Vamp::Plugin::OutputDescriptor::FixedSampleRate; | 127 return Vamp::Plugin::OutputDescriptor::FixedSampleRate; |
125 case SampleType::VARIABLE_SAMPLE_RATE: | 128 case piper::SampleType::VARIABLE_SAMPLE_RATE: |
126 return Vamp::Plugin::OutputDescriptor::VariableSampleRate; | 129 return Vamp::Plugin::OutputDescriptor::VariableSampleRate; |
127 } | 130 } |
128 throw std::logic_error("unexpected Capnp SampleType enum value"); | 131 throw std::logic_error("unexpected Capnp SampleType enum value"); |
129 } | 132 } |
130 | 133 |
131 static void | 134 static void |
132 buildConfiguredOutputDescriptor(ConfiguredOutputDescriptor::Builder &b, | 135 buildConfiguredOutputDescriptor(piper::ConfiguredOutputDescriptor::Builder &b, |
133 const Vamp::Plugin::OutputDescriptor &od) { | 136 const Vamp::Plugin::OutputDescriptor &od) { |
134 | 137 |
135 b.setUnit(od.unit); | 138 b.setUnit(od.unit); |
136 | 139 |
137 b.setSampleType(fromSampleType(od.sampleType)); | 140 b.setSampleType(fromSampleType(od.sampleType)); |
159 b.setQuantizeStep(od.quantizeStep); | 162 b.setQuantizeStep(od.quantizeStep); |
160 } | 163 } |
161 } | 164 } |
162 | 165 |
163 static void | 166 static void |
164 buildOutputDescriptor(OutputDescriptor::Builder &b, | 167 buildOutputDescriptor(piper::OutputDescriptor::Builder &b, |
165 const Vamp::Plugin::OutputDescriptor &od) { | 168 const Vamp::Plugin::OutputDescriptor &od) { |
166 | 169 |
167 auto basic = b.initBasic(); | 170 auto basic = b.initBasic(); |
168 buildBasicDescriptor(basic, od); | 171 buildBasicDescriptor(basic, od); |
169 | 172 |
171 buildConfiguredOutputDescriptor(configured, od); | 174 buildConfiguredOutputDescriptor(configured, od); |
172 } | 175 } |
173 | 176 |
174 static void | 177 static void |
175 readConfiguredOutputDescriptor(Vamp::Plugin::OutputDescriptor &od, | 178 readConfiguredOutputDescriptor(Vamp::Plugin::OutputDescriptor &od, |
176 const ConfiguredOutputDescriptor::Reader &r) { | 179 const piper::ConfiguredOutputDescriptor::Reader &r) { |
177 | 180 |
178 od.unit = r.getUnit(); | 181 od.unit = r.getUnit(); |
179 | 182 |
180 od.sampleType = toSampleType(r.getSampleType()); | 183 od.sampleType = toSampleType(r.getSampleType()); |
181 od.sampleRate = r.getSampleRate(); | 184 od.sampleRate = r.getSampleRate(); |
202 } | 205 } |
203 } | 206 } |
204 | 207 |
205 static void | 208 static void |
206 readOutputDescriptor(Vamp::Plugin::OutputDescriptor &od, | 209 readOutputDescriptor(Vamp::Plugin::OutputDescriptor &od, |
207 const OutputDescriptor::Reader &r) { | 210 const piper::OutputDescriptor::Reader &r) { |
208 | 211 |
209 readBasicDescriptor(od, r.getBasic()); | 212 readBasicDescriptor(od, r.getBasic()); |
210 readConfiguredOutputDescriptor(od, r.getConfigured()); | 213 readConfiguredOutputDescriptor(od, r.getConfigured()); |
211 } | 214 } |
212 | 215 |
213 static void | 216 static void |
214 buildParameterDescriptor(ParameterDescriptor::Builder &b, | 217 buildParameterDescriptor(piper::ParameterDescriptor::Builder &b, |
215 const Vamp::Plugin::ParameterDescriptor &pd) { | 218 const Vamp::Plugin::ParameterDescriptor &pd) { |
216 | 219 |
217 auto basic = b.initBasic(); | 220 auto basic = b.initBasic(); |
218 buildBasicDescriptor(basic, pd); | 221 buildBasicDescriptor(basic, pd); |
219 | 222 |
236 } | 239 } |
237 } | 240 } |
238 | 241 |
239 static void | 242 static void |
240 readParameterDescriptor(Vamp::Plugin::ParameterDescriptor &pd, | 243 readParameterDescriptor(Vamp::Plugin::ParameterDescriptor &pd, |
241 const ParameterDescriptor::Reader &r) { | 244 const piper::ParameterDescriptor::Reader &r) { |
242 | 245 |
243 readBasicDescriptor(pd, r.getBasic()); | 246 readBasicDescriptor(pd, r.getBasic()); |
244 | 247 |
245 pd.unit = r.getUnit(); | 248 pd.unit = r.getUnit(); |
246 | 249 |
259 pd.valueNames.push_back(n); | 262 pd.valueNames.push_back(n); |
260 } | 263 } |
261 } | 264 } |
262 | 265 |
263 static void | 266 static void |
264 buildFeature(Feature::Builder &b, | 267 buildFeature(piper::Feature::Builder &b, |
265 const Vamp::Plugin::Feature &f) { | 268 const Vamp::Plugin::Feature &f) { |
266 | 269 |
267 b.setHasTimestamp(f.hasTimestamp); | 270 b.setHasTimestamp(f.hasTimestamp); |
268 if (f.hasTimestamp) { | 271 if (f.hasTimestamp) { |
269 auto timestamp = b.initTimestamp(); | 272 auto timestamp = b.initTimestamp(); |
286 } | 289 } |
287 } | 290 } |
288 | 291 |
289 static void | 292 static void |
290 readFeature(Vamp::Plugin::Feature &f, | 293 readFeature(Vamp::Plugin::Feature &f, |
291 const Feature::Reader &r) { | 294 const piper::Feature::Reader &r) { |
292 | 295 |
293 f.hasTimestamp = r.getHasTimestamp(); | 296 f.hasTimestamp = r.getHasTimestamp(); |
294 if (f.hasTimestamp) { | 297 if (f.hasTimestamp) { |
295 readRealTime(f.timestamp, r.getTimestamp()); | 298 readRealTime(f.timestamp, r.getTimestamp()); |
296 } | 299 } |
308 f.values.push_back(v); | 311 f.values.push_back(v); |
309 } | 312 } |
310 } | 313 } |
311 | 314 |
312 static void | 315 static void |
313 buildFeatureSet(FeatureSet::Builder &b, | 316 buildFeatureSet(piper::FeatureSet::Builder &b, |
314 const Vamp::Plugin::FeatureSet &fs, | 317 const Vamp::Plugin::FeatureSet &fs, |
315 const PluginOutputIdMapper &omapper) { | 318 const PluginOutputIdMapper &omapper) { |
316 | 319 |
317 auto featureset = b.initFeaturePairs(fs.size()); | 320 auto featureset = b.initFeaturePairs(fs.size()); |
318 int ix = 0; | 321 int ix = 0; |
328 } | 331 } |
329 } | 332 } |
330 | 333 |
331 static void | 334 static void |
332 readFeatureSet(Vamp::Plugin::FeatureSet &fs, | 335 readFeatureSet(Vamp::Plugin::FeatureSet &fs, |
333 const FeatureSet::Reader &r, | 336 const piper::FeatureSet::Reader &r, |
334 const PluginOutputIdMapper &omapper) { | 337 const PluginOutputIdMapper &omapper) { |
335 | 338 |
336 fs.clear(); | 339 fs.clear(); |
337 auto pp = r.getFeaturePairs(); | 340 auto pp = r.getFeaturePairs(); |
338 for (const auto &p: pp) { | 341 for (const auto &p: pp) { |
345 } | 348 } |
346 fs[omapper.idToIndex(p.getOutput())] = vfl; | 349 fs[omapper.idToIndex(p.getOutput())] = vfl; |
347 } | 350 } |
348 } | 351 } |
349 | 352 |
350 static InputDomain | 353 static piper::InputDomain |
351 fromInputDomain(Vamp::Plugin::InputDomain d) { | 354 fromInputDomain(Vamp::Plugin::InputDomain d) { |
352 switch(d) { | 355 switch(d) { |
353 case Vamp::Plugin::TimeDomain: | 356 case Vamp::Plugin::TimeDomain: |
354 return InputDomain::TIME_DOMAIN; | 357 return piper::InputDomain::TIME_DOMAIN; |
355 case Vamp::Plugin::FrequencyDomain: | 358 case Vamp::Plugin::FrequencyDomain: |
356 return InputDomain::FREQUENCY_DOMAIN; | 359 return piper::InputDomain::FREQUENCY_DOMAIN; |
357 default: | 360 default: |
358 throw std::logic_error("unexpected Vamp InputDomain enum value"); | 361 throw std::logic_error("unexpected Vamp InputDomain enum value"); |
359 } | 362 } |
360 } | 363 } |
361 | 364 |
362 static Vamp::Plugin::InputDomain | 365 static Vamp::Plugin::InputDomain |
363 toInputDomain(InputDomain d) { | 366 toInputDomain(piper::InputDomain d) { |
364 switch(d) { | 367 switch(d) { |
365 case InputDomain::TIME_DOMAIN: | 368 case piper::InputDomain::TIME_DOMAIN: |
366 return Vamp::Plugin::TimeDomain; | 369 return Vamp::Plugin::TimeDomain; |
367 case InputDomain::FREQUENCY_DOMAIN: | 370 case piper::InputDomain::FREQUENCY_DOMAIN: |
368 return Vamp::Plugin::FrequencyDomain; | 371 return Vamp::Plugin::FrequencyDomain; |
369 default: | 372 default: |
370 throw std::logic_error("unexpected Capnp InputDomain enum value"); | 373 throw std::logic_error("unexpected Capnp InputDomain enum value"); |
371 } | 374 } |
372 } | 375 } |
373 | 376 |
374 static void | 377 static void |
375 buildExtractorStaticData(ExtractorStaticData::Builder &b, | 378 buildExtractorStaticData(piper::ExtractorStaticData::Builder &b, |
376 const Vamp::HostExt::PluginStaticData &d) { | 379 const PluginStaticData &d) { |
377 | 380 |
378 b.setKey(d.pluginKey); | 381 b.setKey(d.pluginKey); |
379 | 382 |
380 auto basic = b.initBasic(); | 383 auto basic = b.initBasic(); |
381 buildBasicDescriptor(basic, d.basic); | 384 buildBasicDescriptor(basic, d.basic); |
414 buildBasicDescriptor(od, vouts[i]); | 417 buildBasicDescriptor(od, vouts[i]); |
415 } | 418 } |
416 } | 419 } |
417 | 420 |
418 static void | 421 static void |
419 readExtractorStaticData(Vamp::HostExt::PluginStaticData &d, | 422 readExtractorStaticData(PluginStaticData &d, |
420 const ExtractorStaticData::Reader &r) { | 423 const piper::ExtractorStaticData::Reader &r) { |
421 | 424 |
422 d.pluginKey = r.getKey(); | 425 d.pluginKey = r.getKey(); |
423 | 426 |
424 readBasicDescriptor(d.basic, r.getBasic()); | 427 readBasicDescriptor(d.basic, r.getBasic()); |
425 | 428 |
453 d.inputDomain = toInputDomain(r.getInputDomain()); | 456 d.inputDomain = toInputDomain(r.getInputDomain()); |
454 | 457 |
455 d.basicOutputInfo.clear(); | 458 d.basicOutputInfo.clear(); |
456 auto oo = r.getBasicOutputInfo(); | 459 auto oo = r.getBasicOutputInfo(); |
457 for (auto o: oo) { | 460 for (auto o: oo) { |
458 Vamp::HostExt::PluginStaticData::Basic b; | 461 PluginStaticData::Basic b; |
459 readBasicDescriptor(b, o); | 462 readBasicDescriptor(b, o); |
460 d.basicOutputInfo.push_back(b); | 463 d.basicOutputInfo.push_back(b); |
461 } | 464 } |
462 } | 465 } |
463 | 466 |
464 static void | 467 static void |
465 buildConfiguration(Configuration::Builder &b, | 468 buildConfiguration(piper::Configuration::Builder &b, |
466 const Vamp::HostExt::PluginConfiguration &c) { | 469 const PluginConfiguration &c) { |
467 | 470 |
468 const auto &vparams = c.parameterValues; | 471 const auto &vparams = c.parameterValues; |
469 auto params = b.initParameterValues(vparams.size()); | 472 auto params = b.initParameterValues(vparams.size()); |
470 int i = 0; | 473 int i = 0; |
471 for (const auto &pp : vparams) { | 474 for (const auto &pp : vparams) { |
479 b.setStepSize(c.stepSize); | 482 b.setStepSize(c.stepSize); |
480 b.setBlockSize(c.blockSize); | 483 b.setBlockSize(c.blockSize); |
481 } | 484 } |
482 | 485 |
483 static void | 486 static void |
484 readConfiguration(Vamp::HostExt::PluginConfiguration &c, | 487 readConfiguration(PluginConfiguration &c, |
485 const Configuration::Reader &r) { | 488 const piper::Configuration::Reader &r) { |
486 | 489 |
487 auto pp = r.getParameterValues(); | 490 auto pp = r.getParameterValues(); |
488 for (const auto &p: pp) { | 491 for (const auto &p: pp) { |
489 c.parameterValues[p.getParameter()] = p.getValue(); | 492 c.parameterValues[p.getParameter()] = p.getValue(); |
490 } | 493 } |
494 c.stepSize = r.getStepSize(); | 497 c.stepSize = r.getStepSize(); |
495 c.blockSize = r.getBlockSize(); | 498 c.blockSize = r.getBlockSize(); |
496 } | 499 } |
497 | 500 |
498 static void | 501 static void |
499 readListResponse(Vamp::HostExt::ListResponse &lr, | 502 readListResponse(ListResponse &lr, |
500 const ListResponse::Reader &r) { | 503 const piper::ListResponse::Reader &r) { |
501 | 504 |
502 lr.available.clear(); | 505 lr.available.clear(); |
503 auto pp = r.getAvailable(); | 506 auto pp = r.getAvailable(); |
504 for (const auto &p: pp) { | 507 for (const auto &p: pp) { |
505 Vamp::HostExt::PluginStaticData psd; | 508 PluginStaticData psd; |
506 readExtractorStaticData(psd, p); | 509 readExtractorStaticData(psd, p); |
507 lr.available.push_back(psd); | 510 lr.available.push_back(psd); |
508 } | 511 } |
509 } | 512 } |
510 | 513 |
511 static void | 514 static void |
512 buildLoadRequest(LoadRequest::Builder &r, | 515 buildLoadRequest(piper::LoadRequest::Builder &r, |
513 const Vamp::HostExt::LoadRequest &req) { | 516 const LoadRequest &req) { |
514 | 517 |
515 r.setKey(req.pluginKey); | 518 r.setKey(req.pluginKey); |
516 r.setInputSampleRate(req.inputSampleRate); | 519 r.setInputSampleRate(req.inputSampleRate); |
517 | 520 |
518 std::vector<AdapterFlag> flags; | 521 std::vector<piper::AdapterFlag> flags; |
519 if (req.adapterFlags & Vamp::HostExt::PluginLoader::ADAPT_INPUT_DOMAIN) { | 522 if (req.adapterFlags & Vamp::HostExt::PluginLoader::ADAPT_INPUT_DOMAIN) { |
520 flags.push_back(AdapterFlag::ADAPT_INPUT_DOMAIN); | 523 flags.push_back(piper::AdapterFlag::ADAPT_INPUT_DOMAIN); |
521 } | 524 } |
522 if (req.adapterFlags & Vamp::HostExt::PluginLoader::ADAPT_CHANNEL_COUNT) { | 525 if (req.adapterFlags & Vamp::HostExt::PluginLoader::ADAPT_CHANNEL_COUNT) { |
523 flags.push_back(AdapterFlag::ADAPT_CHANNEL_COUNT); | 526 flags.push_back(piper::AdapterFlag::ADAPT_CHANNEL_COUNT); |
524 } | 527 } |
525 if (req.adapterFlags & Vamp::HostExt::PluginLoader::ADAPT_BUFFER_SIZE) { | 528 if (req.adapterFlags & Vamp::HostExt::PluginLoader::ADAPT_BUFFER_SIZE) { |
526 flags.push_back(AdapterFlag::ADAPT_BUFFER_SIZE); | 529 flags.push_back(piper::AdapterFlag::ADAPT_BUFFER_SIZE); |
527 } | 530 } |
528 | 531 |
529 auto f = r.initAdapterFlags(flags.size()); | 532 auto f = r.initAdapterFlags(flags.size()); |
530 for (size_t i = 0; i < flags.size(); ++i) { | 533 for (size_t i = 0; i < flags.size(); ++i) { |
531 f.set(i, flags[i]); | 534 f.set(i, flags[i]); |
532 } | 535 } |
533 } | 536 } |
534 | 537 |
535 static void | 538 static void |
536 readLoadRequest(Vamp::HostExt::LoadRequest &req, | 539 readLoadRequest(LoadRequest &req, |
537 const LoadRequest::Reader &r) { | 540 const piper::LoadRequest::Reader &r) { |
538 | 541 |
539 req.pluginKey = r.getKey(); | 542 req.pluginKey = r.getKey(); |
540 req.inputSampleRate = r.getInputSampleRate(); | 543 req.inputSampleRate = r.getInputSampleRate(); |
541 | 544 |
542 int flags = 0; | 545 int flags = 0; |
543 auto aa = r.getAdapterFlags(); | 546 auto aa = r.getAdapterFlags(); |
544 for (auto a: aa) { | 547 for (auto a: aa) { |
545 if (a == AdapterFlag::ADAPT_INPUT_DOMAIN) { | 548 if (a == piper::AdapterFlag::ADAPT_INPUT_DOMAIN) { |
546 flags |= Vamp::HostExt::PluginLoader::ADAPT_INPUT_DOMAIN; | 549 flags |= Vamp::HostExt::PluginLoader::ADAPT_INPUT_DOMAIN; |
547 } | 550 } |
548 if (a == AdapterFlag::ADAPT_CHANNEL_COUNT) { | 551 if (a == piper::AdapterFlag::ADAPT_CHANNEL_COUNT) { |
549 flags |= Vamp::HostExt::PluginLoader::ADAPT_CHANNEL_COUNT; | 552 flags |= Vamp::HostExt::PluginLoader::ADAPT_CHANNEL_COUNT; |
550 } | 553 } |
551 if (a == AdapterFlag::ADAPT_BUFFER_SIZE) { | 554 if (a == piper::AdapterFlag::ADAPT_BUFFER_SIZE) { |
552 flags |= Vamp::HostExt::PluginLoader::ADAPT_BUFFER_SIZE; | 555 flags |= Vamp::HostExt::PluginLoader::ADAPT_BUFFER_SIZE; |
553 } | 556 } |
554 } | 557 } |
555 req.adapterFlags = flags; | 558 req.adapterFlags = flags; |
556 } | 559 } |
557 | 560 |
558 static void | 561 static void |
559 buildLoadResponse(LoadResponse::Builder &b, | 562 buildLoadResponse(piper::LoadResponse::Builder &b, |
560 const Vamp::HostExt::LoadResponse &resp, | 563 const LoadResponse &resp, |
561 const PluginHandleMapper &pmapper) { | 564 const PluginHandleMapper &pmapper) { |
562 | 565 |
563 b.setHandle(pmapper.pluginToHandle(resp.plugin)); | 566 b.setHandle(pmapper.pluginToHandle(resp.plugin)); |
564 auto sd = b.initStaticData(); | 567 auto sd = b.initStaticData(); |
565 buildExtractorStaticData(sd, resp.staticData); | 568 buildExtractorStaticData(sd, resp.staticData); |
566 auto conf = b.initDefaultConfiguration(); | 569 auto conf = b.initDefaultConfiguration(); |
567 buildConfiguration(conf, resp.defaultConfiguration); | 570 buildConfiguration(conf, resp.defaultConfiguration); |
568 } | 571 } |
569 | 572 |
570 static void | 573 static void |
571 readLoadResponse(Vamp::HostExt::LoadResponse &resp, | 574 readLoadResponse(LoadResponse &resp, |
572 const LoadResponse::Reader &r, | 575 const piper::LoadResponse::Reader &r, |
573 const PluginHandleMapper &pmapper) { | 576 const PluginHandleMapper &pmapper) { |
574 | 577 |
575 resp.plugin = pmapper.handleToPlugin(r.getHandle()); | 578 resp.plugin = pmapper.handleToPlugin(r.getHandle()); |
576 readExtractorStaticData(resp.staticData, r.getStaticData()); | 579 readExtractorStaticData(resp.staticData, r.getStaticData()); |
577 readConfiguration(resp.defaultConfiguration, | 580 readConfiguration(resp.defaultConfiguration, |
578 r.getDefaultConfiguration()); | 581 r.getDefaultConfiguration()); |
579 } | 582 } |
580 | 583 |
581 static void | 584 static void |
582 buildConfigurationRequest(ConfigurationRequest::Builder &b, | 585 buildConfigurationRequest(piper::ConfigurationRequest::Builder &b, |
583 const Vamp::HostExt::ConfigurationRequest &cr, | 586 const ConfigurationRequest &cr, |
584 const PluginHandleMapper &pmapper) { | 587 const PluginHandleMapper &pmapper) { |
585 | 588 |
586 b.setHandle(pmapper.pluginToHandle(cr.plugin)); | 589 b.setHandle(pmapper.pluginToHandle(cr.plugin)); |
587 auto c = b.initConfiguration(); | 590 auto c = b.initConfiguration(); |
588 buildConfiguration(c, cr.configuration); | 591 buildConfiguration(c, cr.configuration); |
589 } | 592 } |
590 | 593 |
591 static void | 594 static void |
592 readConfigurationRequest(Vamp::HostExt::ConfigurationRequest &cr, | 595 readConfigurationRequest(ConfigurationRequest &cr, |
593 const ConfigurationRequest::Reader &r, | 596 const piper::ConfigurationRequest::Reader &r, |
594 const PluginHandleMapper &pmapper) { | 597 const PluginHandleMapper &pmapper) { |
595 | 598 |
596 auto h = r.getHandle(); | 599 auto h = r.getHandle(); |
597 cr.plugin = pmapper.handleToPlugin(h); | 600 cr.plugin = pmapper.handleToPlugin(h); |
598 auto c = r.getConfiguration(); | 601 auto c = r.getConfiguration(); |
599 readConfiguration(cr.configuration, c); | 602 readConfiguration(cr.configuration, c); |
600 } | 603 } |
601 | 604 |
602 static void | 605 static void |
603 buildConfigurationResponse(ConfigurationResponse::Builder &b, | 606 buildConfigurationResponse(piper::ConfigurationResponse::Builder &b, |
604 const Vamp::HostExt::ConfigurationResponse &cr, | 607 const ConfigurationResponse &cr, |
605 const PluginHandleMapper &pmapper) { | 608 const PluginHandleMapper &pmapper) { |
606 | 609 |
607 b.setHandle(pmapper.pluginToHandle(cr.plugin)); | 610 b.setHandle(pmapper.pluginToHandle(cr.plugin)); |
608 auto olist = b.initOutputs(cr.outputs.size()); | 611 auto olist = b.initOutputs(cr.outputs.size()); |
609 for (size_t i = 0; i < cr.outputs.size(); ++i) { | 612 for (size_t i = 0; i < cr.outputs.size(); ++i) { |
611 buildOutputDescriptor(od, cr.outputs[i]); | 614 buildOutputDescriptor(od, cr.outputs[i]); |
612 } | 615 } |
613 } | 616 } |
614 | 617 |
615 static void | 618 static void |
616 readConfigurationResponse(Vamp::HostExt::ConfigurationResponse &cr, | 619 readConfigurationResponse(ConfigurationResponse &cr, |
617 const ConfigurationResponse::Reader &r, | 620 const piper::ConfigurationResponse::Reader &r, |
618 const PluginHandleMapper &pmapper) { | 621 const PluginHandleMapper &pmapper) { |
619 | 622 |
620 cr.plugin = pmapper.handleToPlugin(r.getHandle()); | 623 cr.plugin = pmapper.handleToPlugin(r.getHandle()); |
621 cr.outputs.clear(); | 624 cr.outputs.clear(); |
622 auto oo = r.getOutputs(); | 625 auto oo = r.getOutputs(); |
626 cr.outputs.push_back(desc); | 629 cr.outputs.push_back(desc); |
627 } | 630 } |
628 } | 631 } |
629 | 632 |
630 static void | 633 static void |
631 buildProcessInput(ProcessInput::Builder &b, | 634 buildProcessInput(piper::ProcessInput::Builder &b, |
632 Vamp::RealTime timestamp, | 635 Vamp::RealTime timestamp, |
633 const std::vector<std::vector<float> > &buffers) { | 636 const std::vector<std::vector<float> > &buffers) { |
634 | 637 |
635 auto t = b.initTimestamp(); | 638 auto t = b.initTimestamp(); |
636 buildRealTime(t, timestamp); | 639 buildRealTime(t, timestamp); |
646 } | 649 } |
647 | 650 |
648 static void | 651 static void |
649 readProcessInput(Vamp::RealTime ×tamp, | 652 readProcessInput(Vamp::RealTime ×tamp, |
650 std::vector<std::vector<float> > &buffers, | 653 std::vector<std::vector<float> > &buffers, |
651 const ProcessInput::Reader &b) { | 654 const piper::ProcessInput::Reader &b) { |
652 | 655 |
653 readRealTime(timestamp, b.getTimestamp()); | 656 readRealTime(timestamp, b.getTimestamp()); |
654 buffers.clear(); | 657 buffers.clear(); |
655 auto vv = b.getInputBuffers(); | 658 auto vv = b.getInputBuffers(); |
656 for (const auto &v: vv) { | 659 for (const auto &v: vv) { |
661 buffers.push_back(buf); | 664 buffers.push_back(buf); |
662 } | 665 } |
663 } | 666 } |
664 | 667 |
665 static void | 668 static void |
666 buildProcessRequest(ProcessRequest::Builder &b, | 669 buildProcessRequest(piper::ProcessRequest::Builder &b, |
667 const Vamp::HostExt::ProcessRequest &pr, | 670 const ProcessRequest &pr, |
668 const PluginHandleMapper &pmapper) { | 671 const PluginHandleMapper &pmapper) { |
669 | 672 |
670 b.setHandle(pmapper.pluginToHandle(pr.plugin)); | 673 b.setHandle(pmapper.pluginToHandle(pr.plugin)); |
671 auto input = b.initProcessInput(); | 674 auto input = b.initProcessInput(); |
672 buildProcessInput(input, pr.timestamp, pr.inputBuffers); | 675 buildProcessInput(input, pr.timestamp, pr.inputBuffers); |
673 } | 676 } |
674 | 677 |
675 static void | 678 static void |
676 readProcessRequest(Vamp::HostExt::ProcessRequest &pr, | 679 readProcessRequest(ProcessRequest &pr, |
677 const ProcessRequest::Reader &r, | 680 const piper::ProcessRequest::Reader &r, |
678 const PluginHandleMapper &pmapper) { | 681 const PluginHandleMapper &pmapper) { |
679 | 682 |
680 auto h = r.getHandle(); | 683 auto h = r.getHandle(); |
681 pr.plugin = pmapper.handleToPlugin(h); | 684 pr.plugin = pmapper.handleToPlugin(h); |
682 readProcessInput(pr.timestamp, pr.inputBuffers, r.getProcessInput()); | 685 readProcessInput(pr.timestamp, pr.inputBuffers, r.getProcessInput()); |
683 } | 686 } |
684 | 687 |
685 static void | 688 static void |
686 buildProcessResponse(ProcessResponse::Builder &b, | 689 buildProcessResponse(piper::ProcessResponse::Builder &b, |
687 const Vamp::HostExt::ProcessResponse &pr, | 690 const ProcessResponse &pr, |
688 const PluginHandleMapper &pmapper) { | 691 const PluginHandleMapper &pmapper) { |
689 | 692 |
690 b.setHandle(pmapper.pluginToHandle(pr.plugin)); | 693 b.setHandle(pmapper.pluginToHandle(pr.plugin)); |
691 auto f = b.initFeatures(); | 694 auto f = b.initFeatures(); |
692 buildFeatureSet(f, pr.features, | 695 buildFeatureSet(f, pr.features, |
693 *pmapper.pluginToOutputIdMapper(pr.plugin)); | 696 *pmapper.pluginToOutputIdMapper(pr.plugin)); |
694 } | 697 } |
695 | 698 |
696 static void | 699 static void |
697 readProcessResponse(Vamp::HostExt::ProcessResponse &pr, | 700 readProcessResponse(ProcessResponse &pr, |
698 const ProcessResponse::Reader &r, | 701 const piper::ProcessResponse::Reader &r, |
699 const PluginHandleMapper &pmapper) { | 702 const PluginHandleMapper &pmapper) { |
700 | 703 |
701 auto h = r.getHandle(); | 704 auto h = r.getHandle(); |
702 pr.plugin = pmapper.handleToPlugin(h); | 705 pr.plugin = pmapper.handleToPlugin(h); |
703 readFeatureSet(pr.features, r.getFeatures(), | 706 readFeatureSet(pr.features, r.getFeatures(), |
704 *pmapper.handleToOutputIdMapper(r.getHandle())); | 707 *pmapper.handleToOutputIdMapper(r.getHandle())); |
705 } | 708 } |
706 | 709 |
707 static void | 710 static void |
708 buildFinishResponse(FinishResponse::Builder &b, | 711 buildFinishResponse(piper::FinishResponse::Builder &b, |
709 const Vamp::HostExt::ProcessResponse &pr, | 712 const FinishResponse &pr, |
710 const PluginHandleMapper &pmapper) { | 713 const PluginHandleMapper &pmapper) { |
711 | 714 |
712 b.setHandle(pmapper.pluginToHandle(pr.plugin)); | 715 b.setHandle(pmapper.pluginToHandle(pr.plugin)); |
713 auto f = b.initFeatures(); | 716 auto f = b.initFeatures(); |
714 buildFeatureSet(f, pr.features, | 717 buildFeatureSet(f, pr.features, |
715 *pmapper.pluginToOutputIdMapper(pr.plugin)); | 718 *pmapper.pluginToOutputIdMapper(pr.plugin)); |
716 } | 719 } |
717 | 720 |
718 static void | 721 static void |
719 readFinishResponse(Vamp::HostExt::ProcessResponse &pr, | 722 readFinishResponse(FinishResponse &pr, |
720 const FinishResponse::Reader &r, | 723 const piper::FinishResponse::Reader &r, |
721 const PluginHandleMapper &pmapper) { | 724 const PluginHandleMapper &pmapper) { |
722 | 725 |
723 auto h = r.getHandle(); | 726 auto h = r.getHandle(); |
724 pr.plugin = pmapper.handleToPlugin(h); | 727 pr.plugin = pmapper.handleToPlugin(h); |
725 readFeatureSet(pr.features, r.getFeatures(), | 728 readFeatureSet(pr.features, r.getFeatures(), |
726 *pmapper.handleToOutputIdMapper(r.getHandle())); | 729 *pmapper.handleToOutputIdMapper(r.getHandle())); |
727 } | 730 } |
728 | 731 |
729 static void | 732 static void |
730 buildRpcRequest_List(RpcRequest::Builder &b) { | 733 buildRpcRequest_List(piper::RpcRequest::Builder &b) { |
731 b.getRequest().initList(); | 734 b.getRequest().initList(); |
732 } | 735 } |
733 | 736 |
734 static void | 737 static void |
735 buildRpcResponse_List(RpcResponse::Builder &b, | 738 buildRpcResponse_List(piper::RpcResponse::Builder &b, |
736 const Vamp::HostExt::ListResponse &resp) { | 739 const ListResponse &resp) { |
737 | 740 |
738 auto r = b.getResponse().initList(); | 741 auto r = b.getResponse().initList(); |
739 auto p = r.initAvailable(resp.available.size()); | 742 auto p = r.initAvailable(resp.available.size()); |
740 for (size_t i = 0; i < resp.available.size(); ++i) { | 743 for (size_t i = 0; i < resp.available.size(); ++i) { |
741 auto pd = p[i]; | 744 auto pd = p[i]; |
742 buildExtractorStaticData(pd, resp.available[i]); | 745 buildExtractorStaticData(pd, resp.available[i]); |
743 } | 746 } |
744 } | 747 } |
745 | 748 |
746 static void | 749 static void |
747 buildRpcRequest_Load(RpcRequest::Builder &b, | 750 buildRpcRequest_Load(piper::RpcRequest::Builder &b, |
748 const Vamp::HostExt::LoadRequest &req) { | 751 const LoadRequest &req) { |
749 auto u = b.getRequest().initLoad(); | 752 auto u = b.getRequest().initLoad(); |
750 buildLoadRequest(u, req); | 753 buildLoadRequest(u, req); |
751 } | 754 } |
752 | 755 |
753 static void | 756 static void |
754 buildRpcResponse_Load(RpcResponse::Builder &b, | 757 buildRpcResponse_Load(piper::RpcResponse::Builder &b, |
755 const Vamp::HostExt::LoadResponse &resp, | 758 const LoadResponse &resp, |
756 const PluginHandleMapper &pmapper) { | 759 const PluginHandleMapper &pmapper) { |
757 | 760 |
758 if (resp.plugin) { | 761 if (resp.plugin) { |
759 auto u = b.getResponse().initLoad(); | 762 auto u = b.getResponse().initLoad(); |
760 buildLoadResponse(u, resp, pmapper); | 763 buildLoadResponse(u, resp, pmapper); |
762 buildRpcResponse_Error(b, "Failed to load plugin", RRType::Load); | 765 buildRpcResponse_Error(b, "Failed to load plugin", RRType::Load); |
763 } | 766 } |
764 } | 767 } |
765 | 768 |
766 static void | 769 static void |
767 buildRpcRequest_Configure(RpcRequest::Builder &b, | 770 buildRpcRequest_Configure(piper::RpcRequest::Builder &b, |
768 const Vamp::HostExt::ConfigurationRequest &cr, | 771 const ConfigurationRequest &cr, |
769 const PluginHandleMapper &pmapper) { | 772 const PluginHandleMapper &pmapper) { |
770 auto u = b.getRequest().initConfigure(); | 773 auto u = b.getRequest().initConfigure(); |
771 buildConfigurationRequest(u, cr, pmapper); | 774 buildConfigurationRequest(u, cr, pmapper); |
772 } | 775 } |
773 | 776 |
774 static void | 777 static void |
775 buildRpcResponse_Configure(RpcResponse::Builder &b, | 778 buildRpcResponse_Configure(piper::RpcResponse::Builder &b, |
776 const Vamp::HostExt::ConfigurationResponse &cr, | 779 const ConfigurationResponse &cr, |
777 const PluginHandleMapper &pmapper) { | 780 const PluginHandleMapper &pmapper) { |
778 | 781 |
779 if (!cr.outputs.empty()) { | 782 if (!cr.outputs.empty()) { |
780 auto u = b.getResponse().initConfigure(); | 783 auto u = b.getResponse().initConfigure(); |
781 buildConfigurationResponse(u, cr, pmapper); | 784 buildConfigurationResponse(u, cr, pmapper); |
784 RRType::Configure); | 787 RRType::Configure); |
785 } | 788 } |
786 } | 789 } |
787 | 790 |
788 static void | 791 static void |
789 buildRpcRequest_Process(RpcRequest::Builder &b, | 792 buildRpcRequest_Process(piper::RpcRequest::Builder &b, |
790 const Vamp::HostExt::ProcessRequest &pr, | 793 const ProcessRequest &pr, |
791 const PluginHandleMapper &pmapper) { | 794 const PluginHandleMapper &pmapper) { |
792 auto u = b.getRequest().initProcess(); | 795 auto u = b.getRequest().initProcess(); |
793 buildProcessRequest(u, pr, pmapper); | 796 buildProcessRequest(u, pr, pmapper); |
794 } | 797 } |
795 | 798 |
796 static void | 799 static void |
797 buildRpcResponse_Process(RpcResponse::Builder &b, | 800 buildRpcResponse_Process(piper::RpcResponse::Builder &b, |
798 const Vamp::HostExt::ProcessResponse &pr, | 801 const ProcessResponse &pr, |
799 const PluginHandleMapper &pmapper) { | 802 const PluginHandleMapper &pmapper) { |
800 | 803 |
801 auto u = b.getResponse().initProcess(); | 804 auto u = b.getResponse().initProcess(); |
802 buildProcessResponse(u, pr, pmapper); | 805 buildProcessResponse(u, pr, pmapper); |
803 } | 806 } |
804 | 807 |
805 static void | 808 static void |
806 buildRpcRequest_Finish(RpcRequest::Builder &b, | 809 buildRpcRequest_Finish(piper::RpcRequest::Builder &b, |
807 const Vamp::HostExt::FinishRequest &req, | 810 const FinishRequest &req, |
808 const PluginHandleMapper &pmapper) { | 811 const PluginHandleMapper &pmapper) { |
809 | 812 |
810 auto u = b.getRequest().initFinish(); | 813 auto u = b.getRequest().initFinish(); |
811 u.setHandle(pmapper.pluginToHandle(req.plugin)); | 814 u.setHandle(pmapper.pluginToHandle(req.plugin)); |
812 } | 815 } |
813 | 816 |
814 static void | 817 static void |
815 buildRpcResponse_Finish(RpcResponse::Builder &b, | 818 buildRpcResponse_Finish(piper::RpcResponse::Builder &b, |
816 const Vamp::HostExt::ProcessResponse &pr, | 819 const FinishResponse &pr, |
817 const PluginHandleMapper &pmapper) { | 820 const PluginHandleMapper &pmapper) { |
818 | 821 |
819 auto u = b.getResponse().initFinish(); | 822 auto u = b.getResponse().initFinish(); |
820 buildFinishResponse(u, pr, pmapper); | 823 buildFinishResponse(u, pr, pmapper); |
821 } | 824 } |
822 | 825 |
823 static void | 826 static void |
824 buildRpcResponse_Error(RpcResponse::Builder &b, | 827 buildRpcResponse_Error(piper::RpcResponse::Builder &b, |
825 const std::string &errorText, | 828 const std::string &errorText, |
826 RRType responseType) | 829 RRType responseType) |
827 { | 830 { |
828 std::string type; | 831 std::string type; |
829 | 832 |
846 e.setCode(0); | 849 e.setCode(0); |
847 e.setMessage(std::string("error in ") + type + " request: " + errorText); | 850 e.setMessage(std::string("error in ") + type + " request: " + errorText); |
848 } | 851 } |
849 | 852 |
850 static void | 853 static void |
851 buildRpcResponse_Exception(RpcResponse::Builder &b, | 854 buildRpcResponse_Exception(piper::RpcResponse::Builder &b, |
852 const std::exception &e, | 855 const std::exception &e, |
853 RRType responseType) | 856 RRType responseType) |
854 { | 857 { |
855 return buildRpcResponse_Error(b, e.what(), responseType); | 858 return buildRpcResponse_Error(b, e.what(), responseType); |
856 } | 859 } |
857 | 860 |
858 static RRType | 861 static RRType |
859 getRequestResponseType(const RpcRequest::Reader &r) { | 862 getRequestResponseType(const piper::RpcRequest::Reader &r) { |
860 switch (r.getRequest().which()) { | 863 switch (r.getRequest().which()) { |
861 case RpcRequest::Request::Which::LIST: | 864 case piper::RpcRequest::Request::Which::LIST: |
862 return RRType::List; | 865 return RRType::List; |
863 case RpcRequest::Request::Which::LOAD: | 866 case piper::RpcRequest::Request::Which::LOAD: |
864 return RRType::Load; | 867 return RRType::Load; |
865 case RpcRequest::Request::Which::CONFIGURE: | 868 case piper::RpcRequest::Request::Which::CONFIGURE: |
866 return RRType::Configure; | 869 return RRType::Configure; |
867 case RpcRequest::Request::Which::PROCESS: | 870 case piper::RpcRequest::Request::Which::PROCESS: |
868 return RRType::Process; | 871 return RRType::Process; |
869 case RpcRequest::Request::Which::FINISH: | 872 case piper::RpcRequest::Request::Which::FINISH: |
870 return RRType::Finish; | 873 return RRType::Finish; |
871 } | 874 } |
872 return RRType::NotValid; | 875 return RRType::NotValid; |
873 } | 876 } |
874 | 877 |
875 static RRType | 878 static RRType |
876 getRequestResponseType(const RpcResponse::Reader &r) { | 879 getRequestResponseType(const piper::RpcResponse::Reader &r) { |
877 switch (r.getResponse().which()) { | 880 switch (r.getResponse().which()) { |
878 case RpcResponse::Response::Which::ERROR: | 881 case piper::RpcResponse::Response::Which::ERROR: |
879 return RRType::NotValid; //!!! or error type? test this | 882 return RRType::NotValid; //!!! or error type? test this |
880 case RpcResponse::Response::Which::LIST: | 883 case piper::RpcResponse::Response::Which::LIST: |
881 return RRType::List; | 884 return RRType::List; |
882 case RpcResponse::Response::Which::LOAD: | 885 case piper::RpcResponse::Response::Which::LOAD: |
883 return RRType::Load; | 886 return RRType::Load; |
884 case RpcResponse::Response::Which::CONFIGURE: | 887 case piper::RpcResponse::Response::Which::CONFIGURE: |
885 return RRType::Configure; | 888 return RRType::Configure; |
886 case RpcResponse::Response::Which::PROCESS: | 889 case piper::RpcResponse::Response::Which::PROCESS: |
887 return RRType::Process; | 890 return RRType::Process; |
888 case RpcResponse::Response::Which::FINISH: | 891 case piper::RpcResponse::Response::Which::FINISH: |
889 return RRType::Finish; | 892 return RRType::Finish; |
890 } | 893 } |
891 return RRType::NotValid; | 894 return RRType::NotValid; |
892 } | 895 } |
893 | 896 |
894 static void | 897 static void |
895 readRpcResponse_Error(int &code, | 898 readRpcResponse_Error(int &code, |
896 std::string &message, | 899 std::string &message, |
897 const RpcResponse::Reader &r) { | 900 const piper::RpcResponse::Reader &r) { |
898 if (getRequestResponseType(r) != RRType::NotValid) { | 901 if (getRequestResponseType(r) != RRType::NotValid) { |
899 throw std::logic_error("not an error response"); | 902 throw std::logic_error("not an error response"); |
900 } | 903 } |
901 code = r.getResponse().getError().getCode(); | 904 code = r.getResponse().getError().getCode(); |
902 message = r.getResponse().getError().getMessage(); | 905 message = r.getResponse().getError().getMessage(); |
903 } | 906 } |
904 | 907 |
905 static void | 908 static void |
906 readRpcRequest_List(const RpcRequest::Reader &r) { | 909 readRpcRequest_List(const piper::RpcRequest::Reader &r) { |
907 if (getRequestResponseType(r) != RRType::List) { | 910 if (getRequestResponseType(r) != RRType::List) { |
908 throw std::logic_error("not a list request"); | 911 throw std::logic_error("not a list request"); |
909 } | 912 } |
910 } | 913 } |
911 | 914 |
912 static void | 915 static void |
913 readRpcResponse_List(Vamp::HostExt::ListResponse &resp, | 916 readRpcResponse_List(ListResponse &resp, |
914 const RpcResponse::Reader &r) { | 917 const piper::RpcResponse::Reader &r) { |
915 if (getRequestResponseType(r) != RRType::List) { | 918 if (getRequestResponseType(r) != RRType::List) { |
916 throw std::logic_error("not a list response"); | 919 throw std::logic_error("not a list response"); |
917 } | 920 } |
918 readListResponse(resp, r.getResponse().getList()); | 921 readListResponse(resp, r.getResponse().getList()); |
919 } | 922 } |
920 | 923 |
921 static void | 924 static void |
922 readRpcRequest_Load(Vamp::HostExt::LoadRequest &req, | 925 readRpcRequest_Load(LoadRequest &req, |
923 const RpcRequest::Reader &r) { | 926 const piper::RpcRequest::Reader &r) { |
924 if (getRequestResponseType(r) != RRType::Load) { | 927 if (getRequestResponseType(r) != RRType::Load) { |
925 throw std::logic_error("not a load request"); | 928 throw std::logic_error("not a load request"); |
926 } | 929 } |
927 readLoadRequest(req, r.getRequest().getLoad()); | 930 readLoadRequest(req, r.getRequest().getLoad()); |
928 } | 931 } |
929 | 932 |
930 static void | 933 static void |
931 readRpcResponse_Load(Vamp::HostExt::LoadResponse &resp, | 934 readRpcResponse_Load(LoadResponse &resp, |
932 const RpcResponse::Reader &r, | 935 const piper::RpcResponse::Reader &r, |
933 const PluginHandleMapper &pmapper) { | 936 const PluginHandleMapper &pmapper) { |
934 if (getRequestResponseType(r) != RRType::Load) { | 937 if (getRequestResponseType(r) != RRType::Load) { |
935 throw std::logic_error("not a load response"); | 938 throw std::logic_error("not a load response"); |
936 } | 939 } |
937 resp = {}; | 940 resp = {}; |
938 readLoadResponse(resp, r.getResponse().getLoad(), pmapper); | 941 readLoadResponse(resp, r.getResponse().getLoad(), pmapper); |
939 } | 942 } |
940 | 943 |
941 static void | 944 static void |
942 readRpcRequest_Configure(Vamp::HostExt::ConfigurationRequest &req, | 945 readRpcRequest_Configure(ConfigurationRequest &req, |
943 const RpcRequest::Reader &r, | 946 const piper::RpcRequest::Reader &r, |
944 const PluginHandleMapper &pmapper) { | 947 const PluginHandleMapper &pmapper) { |
945 if (getRequestResponseType(r) != RRType::Configure) { | 948 if (getRequestResponseType(r) != RRType::Configure) { |
946 throw std::logic_error("not a configuration request"); | 949 throw std::logic_error("not a configuration request"); |
947 } | 950 } |
948 readConfigurationRequest(req, r.getRequest().getConfigure(), pmapper); | 951 readConfigurationRequest(req, r.getRequest().getConfigure(), pmapper); |
949 } | 952 } |
950 | 953 |
951 static void | 954 static void |
952 readRpcResponse_Configure(Vamp::HostExt::ConfigurationResponse &resp, | 955 readRpcResponse_Configure(ConfigurationResponse &resp, |
953 const RpcResponse::Reader &r, | 956 const piper::RpcResponse::Reader &r, |
954 const PluginHandleMapper &pmapper) { | 957 const PluginHandleMapper &pmapper) { |
955 if (getRequestResponseType(r) != RRType::Configure) { | 958 if (getRequestResponseType(r) != RRType::Configure) { |
956 throw std::logic_error("not a configuration response"); | 959 throw std::logic_error("not a configuration response"); |
957 } | 960 } |
958 resp = {}; | 961 resp = {}; |
960 r.getResponse().getConfigure(), | 963 r.getResponse().getConfigure(), |
961 pmapper); | 964 pmapper); |
962 } | 965 } |
963 | 966 |
964 static void | 967 static void |
965 readRpcRequest_Process(Vamp::HostExt::ProcessRequest &req, | 968 readRpcRequest_Process(ProcessRequest &req, |
966 const RpcRequest::Reader &r, | 969 const piper::RpcRequest::Reader &r, |
967 const PluginHandleMapper &pmapper) { | 970 const PluginHandleMapper &pmapper) { |
968 if (getRequestResponseType(r) != RRType::Process) { | 971 if (getRequestResponseType(r) != RRType::Process) { |
969 throw std::logic_error("not a process request"); | 972 throw std::logic_error("not a process request"); |
970 } | 973 } |
971 readProcessRequest(req, r.getRequest().getProcess(), pmapper); | 974 readProcessRequest(req, r.getRequest().getProcess(), pmapper); |
972 } | 975 } |
973 | 976 |
974 static void | 977 static void |
975 readRpcResponse_Process(Vamp::HostExt::ProcessResponse &resp, | 978 readRpcResponse_Process(ProcessResponse &resp, |
976 const RpcResponse::Reader &r, | 979 const piper::RpcResponse::Reader &r, |
977 const PluginHandleMapper &pmapper) { | 980 const PluginHandleMapper &pmapper) { |
978 if (getRequestResponseType(r) != RRType::Process) { | 981 if (getRequestResponseType(r) != RRType::Process) { |
979 throw std::logic_error("not a process response"); | 982 throw std::logic_error("not a process response"); |
980 } | 983 } |
981 resp = {}; | 984 resp = {}; |
982 readProcessResponse(resp, r.getResponse().getProcess(), pmapper); | 985 readProcessResponse(resp, r.getResponse().getProcess(), pmapper); |
983 } | 986 } |
984 | 987 |
985 static void | 988 static void |
986 readRpcRequest_Finish(Vamp::HostExt::FinishRequest &req, | 989 readRpcRequest_Finish(FinishRequest &req, |
987 const RpcRequest::Reader &r, | 990 const piper::RpcRequest::Reader &r, |
988 const PluginHandleMapper &pmapper) { | 991 const PluginHandleMapper &pmapper) { |
989 if (getRequestResponseType(r) != RRType::Finish) { | 992 if (getRequestResponseType(r) != RRType::Finish) { |
990 throw std::logic_error("not a finish request"); | 993 throw std::logic_error("not a finish request"); |
991 } | 994 } |
992 req.plugin = pmapper.handleToPlugin | 995 req.plugin = pmapper.handleToPlugin |
993 (r.getRequest().getFinish().getHandle()); | 996 (r.getRequest().getFinish().getHandle()); |
994 } | 997 } |
995 | 998 |
996 static void | 999 static void |
997 readRpcResponse_Finish(Vamp::HostExt::ProcessResponse &resp, | 1000 readRpcResponse_Finish(FinishResponse &resp, |
998 const RpcResponse::Reader &r, | 1001 const piper::RpcResponse::Reader &r, |
999 const PluginHandleMapper &pmapper) { | 1002 const PluginHandleMapper &pmapper) { |
1000 if (getRequestResponseType(r) != RRType::Finish) { | 1003 if (getRequestResponseType(r) != RRType::Finish) { |
1001 throw std::logic_error("not a finish response"); | 1004 throw std::logic_error("not a finish response"); |
1002 } | 1005 } |
1003 resp = {}; | 1006 resp = {}; |