Flatten nested try/catch clauses

This also consistently throws a failed_constructor() when instantiating
SoundFile fails, regardless of the actual exception
This commit is contained in:
Robin Gareus 2019-12-06 18:06:13 +01:00
parent 6d99e1b162
commit 227de8c1b0
No known key found for this signature in database
GPG key ID: A090BCE02CF57F04
2 changed files with 13 additions and 25 deletions

View file

@ -80,9 +80,9 @@ static boost::shared_ptr<ImportableSource>
open_importable_source (const string& path, samplecnt_t samplerate, ARDOUR::SrcQuality quality)
{
/* try libsndfile first, because it can get BWF info from .wav, which ExtAudioFile cannot.
We don't necessarily need that information in an ImportableSource, but it keeps the
logic the same as in SourceFactory::create()
*/
* We don't necessarily need that information in an ImportableSource, but it keeps the
* logic the same as in SourceFactory::create()
*/
try {
boost::shared_ptr<SndFileImportableSource> source(new SndFileImportableSource(path));
@ -92,16 +92,12 @@ open_importable_source (const string& path, samplecnt_t samplerate, ARDOUR::SrcQ
}
/* rewrap as a resampled source */
return boost::shared_ptr<ImportableSource>(new ResampledImportableSource(source, samplerate, quality));
}
catch (...) {
} catch (...) { }
/* libsndfile failed, see if we can use CoreAudio to handle the IO */
#ifdef HAVE_COREAUDIO
/* libsndfile failed, see if we can use CoreAudio to handle the IO */
try {
CAImportableSource* src = new CAImportableSource(path);
boost::shared_ptr<CAImportableSource> source (src);
@ -110,14 +106,11 @@ open_importable_source (const string& path, samplecnt_t samplerate, ARDOUR::SrcQ
}
/* rewrap as a resampled source */
return boost::shared_ptr<ImportableSource>(new ResampledImportableSource(source, samplerate, quality));
#else
throw; // rethrow
} catch (...) { }
#endif
}
throw failed_constructor ();
}
vector<string>

View file

@ -248,27 +248,23 @@ SourceFactory::createExternal (DataType type, Session& s, const string& path,
if (!(flags & Destructive)) {
try {
Source* src = new SndFileSource (s, path, chn, flags);
#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
// boost_debug_shared_ptr_mark_interesting (src, "Source");
#endif
boost::shared_ptr<Source> ret (src);
if (setup_peakfile (ret, defer_peaks)) {
return boost::shared_ptr<Source>();
}
ret->check_for_analysis_data_on_disk ();
if (announce) {
SourceCreated (ret);
}
return ret;
}
} catch (failed_constructor& err) { }
catch (failed_constructor& err) {
#ifdef HAVE_COREAUDIO
try {
Source* src = new CoreAudioSource (s, path, chn, flags);
#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
// boost_debug_shared_ptr_mark_interesting (src, "Source");
@ -282,16 +278,15 @@ SourceFactory::createExternal (DataType type, Session& s, const string& path,
SourceCreated (ret);
}
return ret;
#else
throw; // rethrow
} catch (...) { }
#endif
}
} else {
// eh?
}
throw failed_constructor ();
} else if (type == DataType::MIDI) {
try {