comparison 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
comparison
equal deleted inserted replaced
80:d9e85a65d45b 81:c6b6051b1b1a
3 3
4 #include "vamp-capnp/VampnProto.h" 4 #include "vamp-capnp/VampnProto.h"
5 5
6 #include "vamp-support/AssignedPluginHandleMapper.h" 6 #include "vamp-support/AssignedPluginHandleMapper.h"
7 7
8 namespace piper { 8 namespace piper { //!!! probably something different
9 9
10 class PiperClient : public PiperClientBase 10 class PiperClient : public PiperClientBase
11 { 11 {
12 // unsigned to avoid undefined behaviour on possible wrap
13 typedef uint32_t ReqId;
14
12 public: 15 public:
16
17 PiperClient() { }
18
19 Vamp::Plugin *
20 load(std::string key, float inputSampleRate, int adapterFlags) {
21
22 Vamp::HostExt::LoadRequest request;
23 request.pluginKey = key;
24 request.inputSampleRate = inputSampleRate;
25 request.adapterFlags = adapterFlags;
26
27 ::capnp::MallocMessageBuilder message;
28 RpcRequest::Builder builder = message.initRoot<RpcRequest>();
29
30 VampnProto::buildRpcRequest_Load(builder, request);
31 ReqId id = getId();
32 builder.getId().setNumber(id);
33 };
13 34
14 virtual 35 virtual
15 Vamp::Plugin::OutputList 36 Vamp::Plugin::OutputList
16 configure(PiperStubPlugin *plugin, 37 configure(PiperStubPlugin *plugin,
17 Vamp::HostExt::PluginConfiguration config) { 38 Vamp::HostExt::PluginConfiguration config) {
22 43
23 ::capnp::MallocMessageBuilder message; 44 ::capnp::MallocMessageBuilder message;
24 RpcRequest::Builder builder = message.initRoot<RpcRequest>(); 45 RpcRequest::Builder builder = message.initRoot<RpcRequest>();
25 46
26 VampnProto::buildRpcRequest_Configure(builder, request, m_mapper); 47 VampnProto::buildRpcRequest_Configure(builder, request, m_mapper);
48 ReqId id = getId();
49 builder.getId().setNumber(id);
27 50
28 //!!! now what? 51 //!!! now what?
29 } 52 };
30 53
31 54
32 virtual 55 virtual
33 Vamp::Plugin::FeatureSet 56 Vamp::Plugin::FeatureSet
34 process(PiperStubPlugin *plugin, 57 process(PiperStubPlugin *plugin,
38 virtual Vamp::Plugin::FeatureSet 61 virtual Vamp::Plugin::FeatureSet
39 finish(PiperStubPlugin *plugin) = 0; 62 finish(PiperStubPlugin *plugin) = 0;
40 63
41 private: 64 private:
42 AssignedPluginHandleMapper m_mapper; 65 AssignedPluginHandleMapper m_mapper;
66 int getId() {
67 //!!! todo: mutex
68 static ReqId m_nextId = 0;
69 return m_nextId++;
70 }
43 }; 71 };
44 72
45 } 73 }
46 74