mirror of
https://github.com/Ardour/ardour.git
synced 2025-12-16 11:46:25 +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)
|
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.
|
/* 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
|
* We don't necessarily need that information in an ImportableSource, but it keeps the
|
||||||
logic the same as in SourceFactory::create()
|
* logic the same as in SourceFactory::create()
|
||||||
*/
|
*/
|
||||||
|
|
||||||
try {
|
try {
|
||||||
boost::shared_ptr<SndFileImportableSource> source(new SndFileImportableSource(path));
|
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 */
|
/* rewrap as a resampled source */
|
||||||
|
|
||||||
return boost::shared_ptr<ImportableSource>(new ResampledImportableSource(source, samplerate, quality));
|
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
|
#ifdef HAVE_COREAUDIO
|
||||||
|
try {
|
||||||
/* libsndfile failed, see if we can use CoreAudio to handle the IO */
|
|
||||||
|
|
||||||
CAImportableSource* src = new CAImportableSource(path);
|
CAImportableSource* src = new CAImportableSource(path);
|
||||||
boost::shared_ptr<CAImportableSource> source (src);
|
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 */
|
/* rewrap as a resampled source */
|
||||||
|
|
||||||
return boost::shared_ptr<ImportableSource>(new ResampledImportableSource(source, samplerate, quality));
|
return boost::shared_ptr<ImportableSource>(new ResampledImportableSource(source, samplerate, quality));
|
||||||
|
} catch (...) { }
|
||||||
#else
|
|
||||||
throw; // rethrow
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
}
|
throw failed_constructor ();
|
||||||
}
|
}
|
||||||
|
|
||||||
vector<string>
|
vector<string>
|
||||||
|
|
|
||||||
|
|
@ -248,27 +248,23 @@ SourceFactory::createExternal (DataType type, Session& s, const string& path,
|
||||||
if (!(flags & Destructive)) {
|
if (!(flags & Destructive)) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
||||||
Source* src = new SndFileSource (s, path, chn, flags);
|
Source* src = new SndFileSource (s, path, chn, flags);
|
||||||
#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
|
#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
|
||||||
// boost_debug_shared_ptr_mark_interesting (src, "Source");
|
// boost_debug_shared_ptr_mark_interesting (src, "Source");
|
||||||
#endif
|
#endif
|
||||||
boost::shared_ptr<Source> ret (src);
|
boost::shared_ptr<Source> ret (src);
|
||||||
|
|
||||||
if (setup_peakfile (ret, defer_peaks)) {
|
if (setup_peakfile (ret, defer_peaks)) {
|
||||||
return boost::shared_ptr<Source>();
|
return boost::shared_ptr<Source>();
|
||||||
}
|
}
|
||||||
|
|
||||||
ret->check_for_analysis_data_on_disk ();
|
ret->check_for_analysis_data_on_disk ();
|
||||||
if (announce) {
|
if (announce) {
|
||||||
SourceCreated (ret);
|
SourceCreated (ret);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
}
|
} catch (failed_constructor& err) { }
|
||||||
|
|
||||||
catch (failed_constructor& err) {
|
|
||||||
#ifdef HAVE_COREAUDIO
|
#ifdef HAVE_COREAUDIO
|
||||||
|
try {
|
||||||
Source* src = new CoreAudioSource (s, path, chn, flags);
|
Source* src = new CoreAudioSource (s, path, chn, flags);
|
||||||
#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
|
#ifdef BOOST_SP_ENABLE_DEBUG_HOOKS
|
||||||
// boost_debug_shared_ptr_mark_interesting (src, "Source");
|
// boost_debug_shared_ptr_mark_interesting (src, "Source");
|
||||||
|
|
@ -282,16 +278,15 @@ SourceFactory::createExternal (DataType type, Session& s, const string& path,
|
||||||
SourceCreated (ret);
|
SourceCreated (ret);
|
||||||
}
|
}
|
||||||
return ret;
|
return ret;
|
||||||
|
} catch (...) { }
|
||||||
#else
|
|
||||||
throw; // rethrow
|
|
||||||
#endif
|
#endif
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
// eh?
|
// eh?
|
||||||
}
|
}
|
||||||
|
|
||||||
|
throw failed_constructor ();
|
||||||
|
|
||||||
} else if (type == DataType::MIDI) {
|
} else if (type == DataType::MIDI) {
|
||||||
|
|
||||||
try {
|
try {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue