mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-13 10:06:33 +01:00
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:
parent
6d99e1b162
commit
227de8c1b0
2 changed files with 13 additions and 25 deletions
|
|
@ -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>
|
||||
|
|
|
|||
|
|
@ -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 {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue