comparison vamp-client/AutoPlugin.h @ 134:3dcf0394971d

Debug output improvements, and make the checker actually attempt to call the descriptor function for known plugin types
author Chris Cannam <c.cannam@qmul.ac.uk>
date Wed, 16 Nov 2016 16:12:42 +0000
parents 56e537a7bb99
children
comparison
equal deleted inserted replaced
133:74a7c2a8d6b6 134:3dcf0394971d
48 { 48 {
49 public: 49 public:
50 AutoPlugin(std::string serverName, 50 AutoPlugin(std::string serverName,
51 std::string pluginKey, 51 std::string pluginKey,
52 float inputSampleRate, 52 float inputSampleRate,
53 int adapterFlags) : 53 int adapterFlags,
54 LogCallback *logger) : // logger may be nullptr for cerr
54 Vamp::Plugin(inputSampleRate), 55 Vamp::Plugin(inputSampleRate),
55 m_transport(serverName, "capnp"), 56 m_logger(logger),
56 m_client(&m_transport) 57 m_transport(serverName, "capnp", logger),
58 m_client(&m_transport, logger)
57 { 59 {
58 LoadRequest req; 60 LoadRequest req;
59 req.pluginKey = pluginKey; 61 req.pluginKey = pluginKey;
60 req.inputSampleRate = inputSampleRate; 62 req.inputSampleRate = inputSampleRate;
61 req.adapterFlags = adapterFlags; 63 req.adapterFlags = adapterFlags;
62 try { 64 try {
63 LoadResponse resp = m_client.loadPlugin(req); 65 LoadResponse resp = m_client.loadPlugin(req);
64 m_plugin = resp.plugin; 66 m_plugin = resp.plugin;
65 } catch (ServerCrashed c) { 67 } catch (ServerCrashed c) {
66 std::cerr << c.what() << std::endl; 68 log(std::string("AutoPlugin: Server crashed: ") + c.what());
67 m_plugin = 0; 69 m_plugin = 0;
68 } 70 }
69 } 71 }
70 72
71 virtual ~AutoPlugin() { 73 virtual ~AutoPlugin() {
166 virtual FeatureSet getRemainingFeatures() { 168 virtual FeatureSet getRemainingFeatures() {
167 return getPlugin()->getRemainingFeatures(); 169 return getPlugin()->getRemainingFeatures();
168 } 170 }
169 171
170 private: 172 private:
173 LogCallback *m_logger;
171 ProcessQtTransport m_transport; 174 ProcessQtTransport m_transport;
172 CapnpRRClient m_client; 175 CapnpRRClient m_client;
173 Vamp::Plugin *m_plugin; 176 Vamp::Plugin *m_plugin;
174 Vamp::Plugin *getPlugin() const { 177 Vamp::Plugin *getPlugin() const {
175 if (!m_plugin) { 178 if (!m_plugin) {
176 throw std::logic_error 179 log("AutoPlugin: getPlugin() failed (caller should have called AutoPlugin::isOK)");
177 ("Plugin load failed (should have called AutoPlugin::isOK)"); 180 throw std::logic_error("Plugin load failed");
178 } 181 }
179 return m_plugin; 182 return m_plugin;
183 }
184
185 void log(std::string message) const {
186 if (m_logger) m_logger->log(message);
187 else std::cerr << message << std::endl;
180 } 188 }
181 }; 189 };
182 190
183 } 191 }
184 } 192 }