diff options
Diffstat (limited to 'libs/ardour/source_factory.cc')
-rw-r--r-- | libs/ardour/source_factory.cc | 161 |
1 files changed, 72 insertions, 89 deletions
diff --git a/libs/ardour/source_factory.cc b/libs/ardour/source_factory.cc index 001af609dc..ad01bf6171 100644 --- a/libs/ardour/source_factory.cc +++ b/libs/ardour/source_factory.cc @@ -64,47 +64,26 @@ SourceFactory::create (Session& s, const XMLNode& node) if (type == DataType::AUDIO) { - if (node.property (X_("destructive")) != 0) { - - boost::shared_ptr<Source> ret (new DestructiveFileSource (s, node)); + try { + boost::shared_ptr<Source> ret (new CoreAudioSource (s, node)); if (setup_peakfile (ret)) { return boost::shared_ptr<Source>(); } SourceCreated (ret); return ret; + } - } else { - - try { - boost::shared_ptr<Source> ret (new CoreAudioSource (s, node)); + catch (failed_constructor& err) { + boost::shared_ptr<Source> ret (new SndFileSource (s, node)); if (setup_peakfile (ret)) { return boost::shared_ptr<Source>(); } SourceCreated (ret); return ret; - - } catch (failed_constructor& err) { - - try { - boost::shared_ptr<Source> ret (new CoreAudioSource (node)); - SourceCreated (ret); - return ret; - } - - - catch (failed_constructor& err) { - - boost::shared_ptr<Source> ret (new SndFileSource (s, node)); - if (setup_peakfile (ret)) { - return boost::shared_ptr<Source>(); - } - SourceCreated (ret); - return ret; - } } } else if (type == DataType::MIDI) { - + boost::shared_ptr<Source> ret (new SMFSource (node)); SourceCreated (ret); return ret; @@ -127,33 +106,24 @@ SourceFactory::create (Session& s, const XMLNode& node) if (type == DataType::AUDIO) { - if (node.property (X_("destructive")) != 0) { - - boost::shared_ptr<Source> ret (new DestructiveFileSource (s, node)); - if (setup_peakfile (ret)) { - return boost::shared_ptr<Source>(); - } - SourceCreated (ret); - return ret; + boost::shared_ptr<Source> ret (new SndFileSource (s, node)); - } else { - - boost::shared_ptr<Source> ret (new SndFileSource (s, node)); - if (setup_peakfile (ret)) { - return boost::shared_ptr<Source>(); - } - SourceCreated (ret); - return ret; + if (setup_peakfile (ret)) { + return boost::shared_ptr<Source>(); } + + SourceCreated (ret); + return ret; } else if (type == DataType::MIDI) { boost::shared_ptr<Source> ret (new SMFSource (s, node)); + SourceCreated (ret); return ret; } - + return boost::shared_ptr<Source> (); } @@ -164,39 +134,53 @@ boost::shared_ptr<Source> SourceFactory::createReadable (DataType type, Session& s, string idstr, AudioFileSource::Flag flags, bool announce) { if (type == DataType::AUDIO) { - if (flags & Destructive) { - boost::shared_ptr<Source> ret (new DestructiveFileSource (s, idstr, flags)); - if (setup_peakfile (ret)) { - return boost::shared_ptr<Source>(); - } - if (announce) { - SourceCreated (ret); - } - return ret; - + + if (!(flags & Destructive)) { + try { boost::shared_ptr<Source> ret (new CoreAudioSource (s, idstr, flags)); + if (setup_peakfile (ret)) { + return boost::shared_ptr<Source>(); + } if (announce) { SourceCreated (ret); } return ret; - - } catch (failed_constructor& err) { + } + + catch (failed_constructor& err) { boost::shared_ptr<Source> ret (new SndFileSource (s, idstr, flags)); + if (setup_peakfile (ret)) { + return boost::shared_ptr<Source>(); + } if (announce) { SourceCreated (ret); } return ret; } + } else { + + boost::shared_ptr<Source> ret (new SndFileSource (s, idstr, flags)); + if (setup_peakfile (ret)) { + return boost::shared_ptr<Source>(); + } + if (announce) { + SourceCreated (ret); + } + return ret; + } + } else if (type == DataType::MIDI) { boost::shared_ptr<Source> ret (new SMFSource (s, node)); - SourceCreated (ret); + if (announce) { + SourceCreated (ret); + } return ret; } - + return boost::shared_ptr<Source>(); } @@ -206,27 +190,32 @@ boost::shared_ptr<Source> SourceFactory::createReadable (DataType type, Session& s, string idstr, AudioFileSource::Flag flags, bool announce) { if (type == DataType::AUDIO) { - + boost::shared_ptr<Source> ret (new SndFileSource (s, idstr, flags)); + if (setup_peakfile (ret)) { return boost::shared_ptr<Source>(); } + if (announce) { SourceCreated (ret); } + return ret; } else if (type == DataType::MIDI) { - boost::shared_ptr<Source> ret (new SMFSource (s, idstr, SMFSource::Flag(0))); // FIXME: flags? + // FIXME: flags? + boost::shared_ptr<Source> ret (new SMFSource (s, idstr, SMFSource::Flag(0))); + if (announce) { SourceCreated (ret); } - return ret; + return ret; } - - return boost::shared_ptr<Source> (); + + return boost::shared_ptr<Source>(); } #endif // HAVE_COREAUDIO @@ -235,39 +224,33 @@ boost::shared_ptr<Source> SourceFactory::createWritable (DataType type, Session& s, std::string path, bool destructive, nframes_t rate, bool announce) { /* this might throw failed_constructor(), which is OK */ + if (type == DataType::AUDIO) { - - if (destructive) { - boost::shared_ptr<Source> ret (new DestructiveFileSource (s, path, - Config->get_native_file_data_format(), - Config->get_native_file_header_format(), - rate)); - if (setup_peakfile (ret)) { - return boost::shared_ptr<Source>(); - } - if (announce) { - SourceCreated (ret); - } - } else { - boost::shared_ptr<Source> ret (new SndFileSource (s, path, - Config->get_native_file_data_format(), - Config->get_native_file_header_format(), - rate)); - if (setup_peakfile (ret)) { - return boost::shared_ptr<Source>(); - } - if (announce) { - SourceCreated (ret); - } - return ret; + boost::shared_ptr<Source> ret (new SndFileSource + (s, path, + Config->get_native_file_data_format(), + Config->get_native_file_header_format(), + rate, + (destructive ? AudioFileSource::Flag (SndFileSource::default_writable_flags | AudioFileSource::Destructive) : + SndFileSource::default_writable_flags))); + + if (setup_peakfile (ret)) { + return boost::shared_ptr<Source>(); + } + if (announce) { + SourceCreated (ret); } + return ret; } else if (type == DataType::MIDI) { boost::shared_ptr<Source> ret (new SMFSource (s, path)); - SourceCreated (ret); + + if (announce) { + SourceCreated (ret); + } return ret; - + } return boost::shared_ptr<Source> (); |