From 50c68c6d0cd14525a48ea8f15e779fa92a1069c5 Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Fri, 12 Oct 2007 14:27:47 +0000 Subject: [PATCH] fix peakfile/sourcefactory botch git-svn-id: svn://localhost/ardour2/trunk@2546 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/source_factory.h | 2 +- libs/ardour/source_factory.cc | 119 ++++++++++++++-------------- 2 files changed, 61 insertions(+), 60 deletions(-) diff --git a/libs/ardour/ardour/source_factory.h b/libs/ardour/ardour/source_factory.h index 01f50126a4..7e9be451e8 100644 --- a/libs/ardour/ardour/source_factory.h +++ b/libs/ardour/ardour/source_factory.h @@ -46,7 +46,7 @@ class SourceFactory { static boost::shared_ptr createReadable (DataType type, Session&, std::string path, int chn, AudioFileSource::Flag flags, bool announce = true, bool async = false); static boost::shared_ptr createWritable (DataType type, Session&, std::string name, bool destructive, nframes_t rate, - bool announce = true, bool async = true); + bool announce = true, bool async = false); static Glib::Cond* PeaksToBuild; static Glib::StaticMutex peak_building_lock; diff --git a/libs/ardour/source_factory.cc b/libs/ardour/source_factory.cc index c6b19c8600..d07b9d6d69 100644 --- a/libs/ardour/source_factory.cc +++ b/libs/ardour/source_factory.cc @@ -116,60 +116,66 @@ SourceFactory::createSilent (Session& s, const XMLNode& node, nframes_t nframes, return ret; } -#ifdef USE_COREAUDIO_FOR_FILES boost::shared_ptr SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks) { - try { - boost::shared_ptr ret (new CoreAudioSource (s, node)); - if (!defer_peaks) { - if (setup_peakfile (ret, false)) { - return boost::shared_ptr(); - } - } - SourceCreated (ret); - return ret; - } + DataType type = DataType::AUDIO; + const XMLProperty* prop = node.property("type"); + if (prop) { + type = DataType(prop->value()); + } - catch (failed_constructor& err) { + if (type == DataType::AUDIO) { - /* this is allowed to throw */ +#ifdef HAVE_COREAUDIO - boost::shared_ptr ret (new SndFileSource (s, node)); - if (!defer_peaks) { - if (setup_peakfile (ret, false)) { - return boost::shared_ptr(); - } - } - SourceCreated (ret); - return ret; - } + try { + boost::shared_ptr ret (new CoreAudioSource (s, node)); + + if (setup_peakfile (ret, defer_peaks)) { + return boost::shared_ptr(); + } + + SourceCreated (ret); + return ret; + } + + + catch (failed_constructor& err) { + + /* this is allowed to throw */ + + boost::shared_ptr ret (new SndFileSource (s, node)); + + if (setup_peakfile (ret, defer_peaks)) { + return boost::shared_ptr(); + } + + 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(); + } + + SourceCreated (ret); + return ret; +#endif + + } else if (type == DataType::MIDI) { + + boost::shared_ptr ret (new SMFSource (s, node)); + } return boost::shared_ptr(); } -#else - -boost::shared_ptr -SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks) -{ - /* this is allowed to throw */ - - boost::shared_ptr ret (new SndFileSource (s, node)); - - if (!defer_peaks) { - if (setup_peakfile (ret, false)) { - return boost::shared_ptr(); - } - } - - SourceCreated (ret); - return ret; -} - -#endif // USE_COREAUDIO_FOR_FILES - boost::shared_ptr SourceFactory::createReadable (DataType type, Session& s, string path, int chn, AudioFileSource::Flag flags, bool announce, bool defer_peaks) { @@ -178,11 +184,11 @@ SourceFactory::createReadable (DataType type, Session& s, string path, int chn, #ifdef HAVE_COREAUDIO try { boost::shared_ptr ret (new CoreAudioSource (s, path, chn, flags)); - if (!defer_peaks) { - if (setup_peakfile (ret, false)) { - return boost::shared_ptr(); - } + + if (setup_peakfile (ret, defer_peaks)) { + return boost::shared_ptr(); } + if (announce) { SourceCreated (ret); } @@ -191,10 +197,8 @@ SourceFactory::createReadable (DataType type, Session& s, string path, int chn, catch (failed_constructor& err) { boost::shared_ptr ret (new SndFileSource (s, path, chn, flags)); - if (!defer_peaks) { - if (setup_peakfile (ret, false)) { - return boost::shared_ptr(); - } + if (setup_peakfile (ret, defer_peaks)) { + return boost::shared_ptr(); } if (announce) { SourceCreated (ret); @@ -204,10 +208,8 @@ SourceFactory::createReadable (DataType type, Session& s, string path, int chn, #else boost::shared_ptr ret (new SndFileSource (s, path, chn, flags)); - if (!defer_peaks) { - if (setup_peakfile (ret, false)) { - return boost::shared_ptr(); - } + if (setup_peakfile (ret, defer_peaks)) { + return boost::shared_ptr(); } if (announce) { @@ -246,11 +248,10 @@ SourceFactory::createWritable (DataType type, Session& s, std::string path, bool (destructive ? AudioFileSource::Flag (SndFileSource::default_writable_flags | AudioFileSource::Destructive) : SndFileSource::default_writable_flags))); - if (!defer_peaks) { - if (setup_peakfile (ret, false)) { - return boost::shared_ptr(); - } + if (setup_peakfile (ret, false)) { + return boost::shared_ptr(); } + if (announce) { SourceCreated (ret); }