From 997e4b1f9cd7ccfc704b7c035051da7f60d831e7 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Mon, 17 Mar 2008 20:54:03 +0000 Subject: merge with 2.0-ongoing @ rev 3147 git-svn-id: svn://localhost/ardour2/branches/3.0@3152 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/source_factory.cc | 121 ++++++++++++++++++++---------------------- 1 file changed, 57 insertions(+), 64 deletions(-) (limited to 'libs/ardour/source_factory.cc') diff --git a/libs/ardour/source_factory.cc b/libs/ardour/source_factory.cc index 804d4a4d47..5338997659 100644 --- a/libs/ardour/source_factory.cc +++ b/libs/ardour/source_factory.cc @@ -21,6 +21,7 @@ #include #include #include +#include #include #include @@ -28,10 +29,15 @@ #include #include -#ifdef HAVE_COREAUDIO +#ifdef HAVE_COREAUDIO +#define USE_COREAUDIO_FOR_FILES +#endif + +#ifdef USE_COREAUDIO_FOR_FILES #include #endif + #include "i18n.h" using namespace ARDOUR; @@ -68,6 +74,7 @@ peak_thread_work () if (!as) { continue; } + as->setup_peakfile (); } } @@ -128,48 +135,36 @@ SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks) if (type == DataType::AUDIO) { -#ifdef HAVE_COREAUDIO - try { - boost::shared_ptr ret (new CoreAudioSource (s, node)); - + + boost::shared_ptr ret (new SndFileSource (s, node)); if (setup_peakfile (ret, defer_peaks)) { return boost::shared_ptr(); } - ret->check_for_analysis_data_on_disk (); SourceCreated (ret); return ret; } - - + catch (failed_constructor& err) { +#ifdef USE_COREAUDIO_FOR_FILES + /* this is allowed to throw */ - - boost::shared_ptr ret (new SndFileSource (s, node)); - + + boost::shared_ptr ret (new CoreAudioSource (s, node)); + if (setup_peakfile (ret, defer_peaks)) { return boost::shared_ptr(); } - + ret->check_for_analysis_data_on_disk (); SourceCreated (ret); return ret; - } #else - /* this is allowed to throw */ - - boost::shared_ptr ret (new SndFileSource (s, node)); - - if (setup_peakfile (ret, defer_peaks)) { - return boost::shared_ptr(); - } - - ret->check_for_analysis_data_on_disk (); - SourceCreated (ret); - return ret; + throw; // rethrow #endif + } } else if (type == DataType::MIDI) { boost::shared_ptr ret (new SMFSource (s, node)); @@ -185,59 +180,57 @@ boost::shared_ptr SourceFactory::createReadable (DataType type, Session& s, string path, int chn, AudioFileSource::Flag flags, bool announce, bool defer_peaks) { if (type == DataType::AUDIO) { - -#ifdef HAVE_COREAUDIO - try { - boost::shared_ptr ret (new CoreAudioSource (s, path, chn, flags)); - - if (setup_peakfile (ret, defer_peaks)) { - return boost::shared_ptr(); - } - ret->check_for_analysis_data_on_disk (); - if (announce) { - SourceCreated (ret); - } - return ret; - } - - catch (failed_constructor& err) { - boost::shared_ptr ret (new SndFileSource (s, path, chn, flags)); - if (setup_peakfile (ret, defer_peaks)) { - return boost::shared_ptr(); + if (!(flags & Destructive)) { + + try { + + boost::shared_ptr ret (new SndFileSource (s, path, chn, flags)); + + if (setup_peakfile (ret, defer_peaks)) { + return boost::shared_ptr(); + } + + ret->check_for_analysis_data_on_disk (); + if (announce) { + SourceCreated (ret); + } + return ret; } - ret->check_for_analysis_data_on_disk (); - if (announce) { - SourceCreated (ret); - } - return ret; - } + + catch (failed_constructor& err) { +#ifdef USE_COREAUDIO_FOR_FILES + + boost::shared_ptr ret (new CoreAudioSource (s, path, chn, flags)); + if (setup_peakfile (ret, defer_peaks)) { + return boost::shared_ptr(); + } + ret->check_for_analysis_data_on_disk (); + if (announce) { + SourceCreated (ret); + } + return ret; + #else - boost::shared_ptr ret (new SndFileSource (s, path, chn, flags)); - - if (setup_peakfile (ret, defer_peaks)) { - return boost::shared_ptr(); - } + throw; // rethrow +#endif + } - ret->check_for_analysis_data_on_disk (); - if (announce) { - SourceCreated (ret); + } else { + // eh? } - - return ret; -#endif - + } else if (type == DataType::MIDI) { - + // FIXME: flags? boost::shared_ptr ret (new SMFSource (s, path, SMFSource::Flag(0))); - - ret->check_for_analysis_data_on_disk (); + if (announce) { SourceCreated (ret); } return ret; + } return boost::shared_ptr(); -- cgit v1.2.3