# HG changeset patch # User Chris Cannam # Date 1486576919 0 # Node ID 4b593b6439189fd8a7e59f13db02b188907f5f32 # Parent 648a40f5e322774fb33459d8dcdc4207bf40fc46 Update API usage throughout to match revised framing layout diff -r 648a40f5e322 -r 4b593b643918 Makefile.inc --- a/Makefile.inc Thu Jan 19 09:27:59 2017 +0000 +++ b/Makefile.inc Wed Feb 08 18:01:59 2017 +0000 @@ -46,7 +46,7 @@ $(SDK_DIR)/src/vamp-sdk/FFT.cpp OTHER_SOURCES := \ - $(PIPERCPP_DIR)/json11/json11.cpp + $(PIPERCPP_DIR)/ext/json11/json11.cpp EM_MODULE_EXT := .js EM_MODULE := $(MODULE_NAME)$(EM_MODULE_EXT) @@ -71,7 +71,7 @@ OPTFLAGS ?= -O DEFINES := $(DEFINES) -INCLUDES := -I$(SRC_DIR) -I$(SDK_DIR) -I$(PIPERCPP_DIR) $(INCLUDES) +INCLUDES := -I$(SRC_DIR) -I$(SDK_DIR) -I$(PIPERCPP_DIR) -I$(PIPERCPP_DIR)/ext $(INCLUDES) em: $(EM_MODULE) em: CXX := em++ diff -r 648a40f5e322 -r 4b593b643918 src/PiperPluginLibrary.cpp --- a/src/PiperPluginLibrary.cpp Thu Jan 19 09:27:59 2017 +0000 +++ b/src/PiperPluginLibrary.cpp Wed Feb 08 18:01:59 2017 +0000 @@ -114,7 +114,7 @@ ConfigurationResponse PiperPluginLibrary::configurePlugin(ConfigurationRequest req, - string &err) const + string &err) const { for (PluginConfiguration::ParameterMap::const_iterator i = req.configuration.parameterValues.begin(); @@ -130,12 +130,46 @@ response.plugin = req.plugin; + Framing pluginPreferredFraming; + pluginPreferredFraming.stepSize = req.plugin->getPreferredStepSize(); + pluginPreferredFraming.blockSize = req.plugin->getPreferredBlockSize(); + + if (req.plugin->initialise(req.configuration.channelCount, - req.configuration.stepSize, - req.configuration.blockSize)) { + req.configuration.framing.stepSize, + req.configuration.framing.blockSize)) { + response.outputs = req.plugin->getOutputDescriptors(); + + // If the Vamp plugin initialise() call succeeds, then by + // definition it is accepting the step and block size we + // passed to it + response.framing = req.configuration.framing; + } else { - err = "configuration failed (wrong channel count, step size, block size?)"; + + // If initialise() fails, one reason could be that it didn't + // like the passed-in framing (step and block size). We need + // to check whether the passed-in framing differs from the + // plugin's preferences; if so, then we form a working + // supposition that initialise() failed because of this. Vamp + // contains nothing to allow us to test this, except to try + // initialise() again with different values. So we try again + // with the values the plugin told us it would prefer and, if + // that succeeds, return them in a successful response. + // + // See also LoaderRequests in piper-cpp/vamp-support. + // + if (req.plugin->initialise(req.configuration.channelCount, + pluginPreferredFraming.stepSize, + pluginPreferredFraming.blockSize)) { + + response.outputs = req.plugin->getOutputDescriptors(); + response.framing = pluginPreferredFraming; + + } else { + err = "configuration failed (wrong channel count, step size, block size?)"; + } } return response; @@ -248,7 +282,7 @@ } else { m_mapper.markConfigured(h, req.configuration.channelCount, - req.configuration.blockSize); + req.configuration.framing.blockSize); rj = VampJson::fromRpcResponse_Configure(resp, m_mapper, id); } } diff -r 648a40f5e322 -r 4b593b643918 test/node-load-test.js --- a/test/node-load-test.js Thu Jan 19 09:27:59 2017 +0000 +++ b/test/node-load-test.js Wed Feb 08 18:01:59 2017 +0000 @@ -183,22 +183,27 @@ }); checkSuccess(response); - const blockSize = response.result.defaultConfiguration.blockSize; - const stepSize = response.result.defaultConfiguration.stepSize; + var blockSize = response.result.defaultConfiguration.framing.blockSize; + var stepSize = response.result.defaultConfiguration.framing.stepSize; response = request({ method: "configure", params: { handle: 1, configuration: { - blockSize: blockSize, - stepSize: stepSize, + framing: { + blockSize: blockSize, + stepSize: stepSize, + }, channelCount: 1 } } }); checkSuccess(response); + blockSize = response.result.framing.blockSize; + stepSize = response.result.framing.stepSize; + const nblocks = 1000; const makeBlock = (n => {