Fix a crash in rhythm ferret if the relevant plugin couldn't be found for some reason

The crash was caused by not catching 'failed_constructor()' (which gets thrown in the c'tor for AudioAnalyser).
This commit is contained in:
John Emmas 2017-02-04 12:58:33 +00:00
parent d1599abad3
commit efd859a0ee

View file

@ -253,28 +253,34 @@ RhythmFerret::run_analysis ()
int int
RhythmFerret::run_percussion_onset_analysis (boost::shared_ptr<Readable> readable, frameoffset_t /*offset*/, AnalysisFeatureList& results) RhythmFerret::run_percussion_onset_analysis (boost::shared_ptr<Readable> readable, frameoffset_t /*offset*/, AnalysisFeatureList& results)
{ {
TransientDetector t (_session->frame_rate()); try {
TransientDetector t (_session->frame_rate());
for (uint32_t i = 0; i < readable->n_channels(); ++i) { for (uint32_t i = 0; i < readable->n_channels(); ++i) {
AnalysisFeatureList these_results; AnalysisFeatureList these_results;
t.reset (); t.reset ();
float dB = detection_threshold_adjustment.get_value(); float dB = detection_threshold_adjustment.get_value();
float coeff = dB > -80.0f ? pow (10.0f, dB * 0.05f) : 0.0f; float coeff = dB > -80.0f ? pow (10.0f, dB * 0.05f) : 0.0f;
t.set_threshold (coeff); t.set_threshold (coeff);
t.set_sensitivity (4, sensitivity_adjustment.get_value()); t.set_sensitivity (4, sensitivity_adjustment.get_value());
if (t.run ("", readable.get(), i, these_results)) { if (t.run ("", readable.get(), i, these_results)) {
continue; continue;
}
/* merge */
results.insert (results.end(), these_results.begin(), these_results.end());
these_results.clear ();
t.update_positions (readable.get(), i, results);
} }
/* merge */ } catch (failed_constructor& err) {
error << "Could not load percussion onset detection plugin" << endmsg;
results.insert (results.end(), these_results.begin(), these_results.end()); return -1;
these_results.clear ();
t.update_positions (readable.get(), i, results);
} }
return 0; return 0;