Mercurial > hg > piper-cpp
changeset 88:bf2e6f939f9f
Rename, + adjust finish
author | Chris Cannam <c.cannam@qmul.ac.uk> |
---|---|
date | Wed, 12 Oct 2016 19:02:31 +0100 |
parents | 7a77a374b6b2 |
children | 03ed2e0a6c8f |
files | vamp-client/client.cpp vamp-client/stub.h |
diffstat | 2 files changed, 14 insertions(+), 13 deletions(-) [+] |
line wrap: on
line diff
--- a/vamp-client/client.cpp Wed Oct 12 17:47:59 2016 +0100 +++ b/vamp-client/client.cpp Wed Oct 12 19:02:31 2016 +0100 @@ -30,7 +30,7 @@ namespace piper { //!!! probably something different -class PiperClient : public PiperClientBase +class PiperClient : public PiperClientStubRequirements { // unsigned to avoid undefined behaviour on possible wrap typedef uint32_t ReqId; @@ -60,6 +60,10 @@ //!!! obviously, factor out all repetitive guff + //!!! list and load are supposed to be called by application code, + //!!! but the rest are only supposed to be called by the plugin -- + //!!! sort out the api here + Vamp::Plugin * load(std::string key, float inputSampleRate, int adapterFlags) { @@ -88,7 +92,6 @@ QByteArray buffer = readResponseBuffer(); auto karr = toKJArray(buffer); capnp::FlatArrayMessageReader responseMessage(karr); - cerr << "made reader" << endl; RpcResponse::Reader reader = responseMessage.getRoot<RpcResponse>(); //!!! handle (explicit) error case @@ -229,7 +232,9 @@ m_mapper); m_mapper.removePlugin(m_mapper.pluginToHandle(plugin)); - delete plugin; + + // Don't delete the plugin. It's the plugin that is supposed + // to be calling us here return pr.features; } @@ -249,7 +254,6 @@ // see whether it matters first size_t wordSize = sizeof(capnp::word); size_t words = qarr.size() / wordSize; - cerr << "converting " << words << " words (" << (words * wordSize) << " bytes)" << endl; kj::Array<capnp::word> karr(kj::heapArray<capnp::word>(words)); memcpy(karr.begin(), qarr.data(), words * wordSize); return karr; @@ -278,9 +282,6 @@ size_t haveWords = buffer.size() / wordSize; size_t expectedWords = capnp::expectedSizeInWordsFromPrefix(toKJArray(buffer)); - - cerr << "haveWords = " << haveWords << ", expectedWords = " << expectedWords << endl; - if (haveWords >= expectedWords) { if (haveWords > expectedWords) { cerr << "WARNING: obtained more data than expected (" @@ -335,9 +336,9 @@ cerr << f.values[0] << endl; } } - //!!! todo: make it possible to do both of the following -- + (void)plugin->getRemainingFeatures(); -// delete plugin; + delete plugin; //!!! -- and also implement reset(), which will need to reconstruct internally }
--- a/vamp-client/stub.h Wed Oct 12 17:47:59 2016 +0100 +++ b/vamp-client/stub.h Wed Oct 12 19:02:31 2016 +0100 @@ -10,7 +10,7 @@ class PiperStubPlugin; -class PiperClientBase +class PiperClientStubRequirements { public: virtual @@ -35,7 +35,7 @@ }; public: - PiperStubPlugin(PiperClientBase *client, + PiperStubPlugin(PiperClientStubRequirements *client, float inputSampleRate, Vamp::HostExt::PluginStaticData psd, Vamp::HostExt::PluginConfiguration defaultConfig) : @@ -49,7 +49,7 @@ virtual ~PiperStubPlugin() { if (m_state != Finished) { - std::cerr << "WARNING: PiperStubPlugin destroyed without finish() call, may be a server-side resource leak" << std::endl; + (void)m_client->finish(this); } } @@ -215,7 +215,7 @@ } private: - PiperClientBase *m_client; + PiperClientStubRequirements *m_client; State m_state; Vamp::HostExt::PluginStaticData m_psd; OutputList m_outputs;