annotate vamp-client/client.cpp @ 81:c6b6051b1b1a

Build rpcrequest types. May be a misdirection
author Chris Cannam <c.cannam@qmul.ac.uk>
date Tue, 11 Oct 2016 16:25:52 +0100
parents d9e85a65d45b
children fa2c0358c2b6
rev   line source
c@78 1
c@78 2 #include "stub.h"
c@78 3
c@80 4 #include "vamp-capnp/VampnProto.h"
c@80 5
c@80 6 #include "vamp-support/AssignedPluginHandleMapper.h"
c@80 7
c@81 8 namespace piper { //!!! probably something different
c@80 9
c@80 10 class PiperClient : public PiperClientBase
c@80 11 {
c@81 12 // unsigned to avoid undefined behaviour on possible wrap
c@81 13 typedef uint32_t ReqId;
c@81 14
c@80 15 public:
c@81 16
c@81 17 PiperClient() { }
c@81 18
c@81 19 Vamp::Plugin *
c@81 20 load(std::string key, float inputSampleRate, int adapterFlags) {
c@81 21
c@81 22 Vamp::HostExt::LoadRequest request;
c@81 23 request.pluginKey = key;
c@81 24 request.inputSampleRate = inputSampleRate;
c@81 25 request.adapterFlags = adapterFlags;
c@81 26
c@81 27 ::capnp::MallocMessageBuilder message;
c@81 28 RpcRequest::Builder builder = message.initRoot<RpcRequest>();
c@81 29
c@81 30 VampnProto::buildRpcRequest_Load(builder, request);
c@81 31 ReqId id = getId();
c@81 32 builder.getId().setNumber(id);
c@81 33 };
c@80 34
c@80 35 virtual
c@80 36 Vamp::Plugin::OutputList
c@80 37 configure(PiperStubPlugin *plugin,
c@80 38 Vamp::HostExt::PluginConfiguration config) {
c@80 39
c@80 40 Vamp::HostExt::ConfigurationRequest request;
c@80 41 request.plugin = plugin;
c@80 42 request.configuration = config;
c@80 43
c@80 44 ::capnp::MallocMessageBuilder message;
c@80 45 RpcRequest::Builder builder = message.initRoot<RpcRequest>();
c@80 46
c@80 47 VampnProto::buildRpcRequest_Configure(builder, request, m_mapper);
c@81 48 ReqId id = getId();
c@81 49 builder.getId().setNumber(id);
c@80 50
c@80 51 //!!! now what?
c@81 52 };
c@80 53
c@80 54
c@80 55 virtual
c@80 56 Vamp::Plugin::FeatureSet
c@80 57 process(PiperStubPlugin *plugin,
c@80 58 const float *const *inputBuffers,
c@80 59 Vamp::RealTime timestamp) = 0;
c@80 60
c@80 61 virtual Vamp::Plugin::FeatureSet
c@80 62 finish(PiperStubPlugin *plugin) = 0;
c@80 63
c@80 64 private:
c@80 65 AssignedPluginHandleMapper m_mapper;
c@81 66 int getId() {
c@81 67 //!!! todo: mutex
c@81 68 static ReqId m_nextId = 0;
c@81 69 return m_nextId++;
c@81 70 }
c@80 71 };
c@80 72
c@80 73 }
c@80 74