diff options
author | Robin Gareus <robin@gareus.org> | 2019-12-06 18:06:13 +0100 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2019-12-06 18:16:10 +0100 |
commit | 227de8c1b04b68c9e50b6de5adaac435f257f33c (patch) | |
tree | aad71ddd69728650e5f99889bea554b726b630a5 | |
parent | 6d99e1b1622dfc4e568dc6efc566a1192a3c123a (diff) |
Flatten nested try/catch clauses
This also consistently throws a failed_constructor() when instantiating
SoundFile fails, regardless of the actual exception
-rw-r--r-- | libs/ardour/import.cc | 23 | ||||
-rw-r--r-- | libs/ardour/source_factory.cc | 15 |
2 files changed, 13 insertions, 25 deletions
diff --git a/libs/ardour/import.cc b/libs/ardour/import.cc index ee6bd6db89..578be0956a 100644 --- a/libs/ardour/import.cc +++ b/libs/ardour/import.cc @@ -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> diff --git a/libs/ardour/source_factory.cc b/libs/ardour/source_factory.cc index 622c535263..3375ff9f0d 100644 --- a/libs/ardour/source_factory.cc +++ b/libs/ardour/source_factory.cc @@ -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 { |