comparison vamp-client/CapnpRRClient.h @ 142:9768b5ca710a

Log function entry/exit points (optionally)
author Chris Cannam <c.cannam@qmul.ac.uk>
date Wed, 18 Jan 2017 14:13:21 +0000
parents 3dcf0394971d
children 654e85cc3ba1
comparison
equal deleted inserted replaced
141:c3ddc4a72561 142:9768b5ca710a
45 #include "vamp-capnp/VampnProto.h" 45 #include "vamp-capnp/VampnProto.h"
46 46
47 #include <sstream> 47 #include <sstream>
48 48
49 #include <capnp/serialize.h> 49 #include <capnp/serialize.h>
50
51 #define LOG_ENTRYPOINTS 1
52
53 #ifdef LOG_ENTRYPOINTS
54 #define LOG_E(x) log(x)
55 #else
56 #define LOG_E(x)
57 #endif
50 58
51 namespace piper_vamp { 59 namespace piper_vamp {
52 namespace client { 60 namespace client {
53 61
54 /** 62 /**
103 // Loader methods: 111 // Loader methods:
104 112
105 ListResponse 113 ListResponse
106 listPluginData(const ListRequest &req) override { 114 listPluginData(const ListRequest &req) override {
107 115
116 LOG_E("CapnpRRClient::listPluginData called");
117
108 if (!m_transport->isOK()) { 118 if (!m_transport->isOK()) {
109 log("Piper server crashed or failed to start (caller should have checked this)"); 119 log("Piper server crashed or failed to start (caller should have checked this)");
110 throw std::runtime_error("Piper server crashed or failed to start"); 120 throw std::runtime_error("Piper server crashed or failed to start");
111 } 121 }
112 122
123 133
124 checkResponseType(reader, piper::RpcResponse::Response::Which::LIST, id); 134 checkResponseType(reader, piper::RpcResponse::Response::Which::LIST, id);
125 135
126 ListResponse lr; 136 ListResponse lr;
127 VampnProto::readListResponse(lr, reader.getResponse().getList()); 137 VampnProto::readListResponse(lr, reader.getResponse().getList());
138
139 LOG_E("CapnpRRClient::listPluginData returning");
140
128 return lr; 141 return lr;
129 } 142 }
130 143
131 LoadResponse 144 LoadResponse
132 loadPlugin(const LoadRequest &req) override { 145 loadPlugin(const LoadRequest &req) override {
133 146
147 LOG_E("CapnpRRClient::loadPlugin called");
148
134 if (!m_transport->isOK()) { 149 if (!m_transport->isOK()) {
135 log("Piper server crashed or failed to start (caller should have checked this)"); 150 log("Piper server crashed or failed to start (caller should have checked this)");
136 throw std::runtime_error("Piper server crashed or failed to start"); 151 throw std::runtime_error("Piper server crashed or failed to start");
137 } 152 }
138 153
151 resp.defaultConfiguration); 166 resp.defaultConfiguration);
152 167
153 m_mapper.addPlugin(handle, plugin); 168 m_mapper.addPlugin(handle, plugin);
154 169
155 resp.plugin = plugin; 170 resp.plugin = plugin;
171
172 LOG_E("CapnpRRClient::loadPlugin returning");
173
156 return resp; 174 return resp;
157 } 175 }
158 176
159 // PluginClient methods: 177 // PluginClient methods:
160 178
161 virtual 179 virtual
162 Vamp::Plugin::OutputList 180 Vamp::Plugin::OutputList
163 configure(PluginStub *plugin, 181 configure(PluginStub *plugin,
164 PluginConfiguration config) override { 182 PluginConfiguration config) override {
165 183
184 LOG_E("CapnpRRClient::configure called");
185
166 if (!m_transport->isOK()) { 186 if (!m_transport->isOK()) {
167 log("Piper server crashed or failed to start (caller should have checked this)"); 187 log("Piper server crashed or failed to start (caller should have checked this)");
168 throw std::runtime_error("Piper server crashed or failed to start"); 188 throw std::runtime_error("Piper server crashed or failed to start");
169 } 189 }
170 190
191 ConfigurationResponse cr; 211 ConfigurationResponse cr;
192 VampnProto::readConfigurationResponse(cr, 212 VampnProto::readConfigurationResponse(cr,
193 reader.getResponse().getConfigure(), 213 reader.getResponse().getConfigure(),
194 m_mapper); 214 m_mapper);
195 215
216 LOG_E("CapnpRRClient::configure returning");
217
196 return cr.outputs; 218 return cr.outputs;
197 }; 219 };
198 220
199 virtual 221 virtual
200 Vamp::Plugin::FeatureSet 222 Vamp::Plugin::FeatureSet
201 process(PluginStub *plugin, 223 process(PluginStub *plugin,
202 std::vector<std::vector<float> > inputBuffers, 224 std::vector<std::vector<float> > inputBuffers,
203 Vamp::RealTime timestamp) override { 225 Vamp::RealTime timestamp) override {
204 226
227 LOG_E("CapnpRRClient::process called");
228
205 if (!m_transport->isOK()) { 229 if (!m_transport->isOK()) {
206 log("Piper server crashed or failed to start (caller should have checked this)"); 230 log("Piper server crashed or failed to start (caller should have checked this)");
207 throw std::runtime_error("Piper server crashed or failed to start"); 231 throw std::runtime_error("Piper server crashed or failed to start");
208 } 232 }
209 233
230 ProcessResponse pr; 254 ProcessResponse pr;
231 VampnProto::readProcessResponse(pr, 255 VampnProto::readProcessResponse(pr,
232 reader.getResponse().getProcess(), 256 reader.getResponse().getProcess(),
233 m_mapper); 257 m_mapper);
234 258
259 LOG_E("CapnpRRClient::process returning");
260
235 return pr.features; 261 return pr.features;
236 } 262 }
237 263
238 virtual Vamp::Plugin::FeatureSet 264 virtual Vamp::Plugin::FeatureSet
239 finish(PluginStub *plugin) override { 265 finish(PluginStub *plugin) override {
240 266
267 LOG_E("CapnpRRClient::finish called");
268
241 if (!m_transport->isOK()) { 269 if (!m_transport->isOK()) {
242 log("Piper server crashed or failed to start (caller should have checked this)"); 270 log("Piper server crashed or failed to start (caller should have checked this)");
243 throw std::runtime_error("Piper server crashed or failed to start"); 271 throw std::runtime_error("Piper server crashed or failed to start");
244 } 272 }
245 273
269 297
270 m_mapper.removePlugin(m_mapper.pluginToHandle(plugin)); 298 m_mapper.removePlugin(m_mapper.pluginToHandle(plugin));
271 299
272 // Don't delete the plugin. It's the plugin that is supposed 300 // Don't delete the plugin. It's the plugin that is supposed
273 // to be calling us here 301 // to be calling us here
302
303 LOG_E("CapnpRRClient::finish returning");
274 304
275 return pr.features; 305 return pr.features;
276 } 306 }
277 307
278 virtual void 308 virtual void