Mercurial > hg > piper-cpp
comparison vamp-client/PluginStub.h @ 169:f13dc1db2229
Trap and rethrow after locking into failed state
author | Chris Cannam <cannam@all-day-breakfast.com> |
---|---|
date | Tue, 31 Jan 2017 11:26:07 +0000 |
parents | 4a37daf5f8b4 |
children | 590b1a1fd955 |
comparison
equal
deleted
inserted
replaced
167:4a37daf5f8b4 | 169:f13dc1db2229 |
---|---|
164 | 164 |
165 m_config.channelCount = int(inputChannels); | 165 m_config.channelCount = int(inputChannels); |
166 m_config.stepSize = int(stepSize); | 166 m_config.stepSize = int(stepSize); |
167 m_config.blockSize = int(blockSize); | 167 m_config.blockSize = int(blockSize); |
168 | 168 |
169 m_outputs = m_client->configure(this, m_config); | 169 try { |
170 m_outputs = m_client->configure(this, m_config); | |
171 } catch (const std::exception &e) { | |
172 m_state = Failed; | |
173 throw; | |
174 } | |
170 | 175 |
171 if (!m_outputs.empty()) { | 176 if (!m_outputs.empty()) { |
172 m_state = Configured; | 177 m_state = Configured; |
173 return true; | 178 return true; |
174 } else { | 179 } else { |
183 } | 188 } |
184 if (m_state == Loaded) { | 189 if (m_state == Loaded) { |
185 // reset is a no-op if the plugin hasn't been initialised yet | 190 // reset is a no-op if the plugin hasn't been initialised yet |
186 return; | 191 return; |
187 } | 192 } |
188 | 193 |
189 m_client->reset(this, m_config); | 194 try { |
195 m_client->reset(this, m_config); | |
196 } catch (const std::exception &e) { | |
197 m_state = Failed; | |
198 throw; | |
199 } | |
190 | 200 |
191 m_state = Configured; | 201 m_state = Configured; |
192 } | 202 } |
193 | 203 |
194 virtual InputDomain getInputDomain() const { | 204 virtual InputDomain getInputDomain() const { |
256 for (int c = 0; c < m_config.channelCount; ++c) { | 266 for (int c = 0; c < m_config.channelCount; ++c) { |
257 vecbuf.push_back(std::vector<float> | 267 vecbuf.push_back(std::vector<float> |
258 (inputBuffers[c], | 268 (inputBuffers[c], |
259 inputBuffers[c] + m_config.blockSize)); | 269 inputBuffers[c] + m_config.blockSize)); |
260 } | 270 } |
261 | 271 |
262 return m_client->process(this, vecbuf, timestamp); | 272 try { |
273 return m_client->process(this, vecbuf, timestamp); | |
274 } catch (const std::exception &e) { | |
275 m_state = Failed; | |
276 throw; | |
277 } | |
263 } | 278 } |
264 | 279 |
265 virtual FeatureSet getRemainingFeatures() { | 280 virtual FeatureSet getRemainingFeatures() { |
266 | 281 |
267 if (m_state == Failed) { | 282 if (m_state == Failed) { |
276 throw std::logic_error("Plugin has already been disposed of"); | 291 throw std::logic_error("Plugin has already been disposed of"); |
277 } | 292 } |
278 | 293 |
279 m_state = Finished; | 294 m_state = Finished; |
280 | 295 |
281 return m_client->finish(this); | 296 try { |
297 return m_client->finish(this); | |
298 } catch (const std::exception &e) { | |
299 m_state = Failed; | |
300 throw; | |
301 } | |
282 } | 302 } |
283 | 303 |
284 // Not Plugin methods, but needed by the PluginClient to support reloads: | 304 // Not Plugin methods, but needed by the PluginClient to support reloads: |
285 | 305 |
286 virtual float getInputSampleRate() const { | 306 virtual float getInputSampleRate() const { |