From 7bd41538d951c3e476655df741adfbebbb990bde Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 19 Sep 2006 03:29:16 +0000 Subject: Merged with trunk R920. git-svn-id: svn://localhost/ardour2/branches/midi@921 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/source_factory.cc | 81 +++++++++++++++++++++++++------------------ 1 file changed, 47 insertions(+), 34 deletions(-) (limited to 'libs/ardour/source_factory.cc') diff --git a/libs/ardour/source_factory.cc b/libs/ardour/source_factory.cc index 61a7659a5e..29cd5166ff 100644 --- a/libs/ardour/source_factory.cc +++ b/libs/ardour/source_factory.cc @@ -37,7 +37,7 @@ sigc::signal > SourceFactory::SourceCreated; #ifdef HAVE_COREAUDIO boost::shared_ptr -SourceFactory::create (const XMLNode& node) +SourceFactory::create (Session& s, const XMLNode& node) { DataType type = DataType::AUDIO; const XMLProperty* prop = node.property("type"); @@ -49,11 +49,18 @@ SourceFactory::create (const XMLNode& node) if (node.property (X_("destructive")) != 0) { - boost::shared_ptr ret (new DestructiveFileSource (node)); + boost::shared_ptr ret (new DestructiveFileSource (s, node)); SourceCreated (ret); return ret; } else { + + try { + boost::shared_ptr ret (new CoreAudioSource (s, node)); + SourceCreated (ret); + return ret; + + } catch (failed_constructor& err) { try { boost::shared_ptr ret (new CoreAudioSource (node)); @@ -83,7 +90,7 @@ SourceFactory::create (const XMLNode& node) #else boost::shared_ptr -SourceFactory::create (const XMLNode& node) +SourceFactory::create (Session& s, const XMLNode& node) { DataType type = DataType::AUDIO; const XMLProperty* prop = node.property("type"); @@ -95,20 +102,20 @@ SourceFactory::create (const XMLNode& node) if (node.property (X_("destructive")) != 0) { - boost::shared_ptr ret (new DestructiveFileSource (node)); + boost::shared_ptr ret (new DestructiveFileSource (s, node)); SourceCreated (ret); return ret; } else { - boost::shared_ptr ret (new SndFileSource (node)); + boost::shared_ptr ret (new SndFileSource (s, node)); SourceCreated (ret); return ret; } } else if (type == DataType::MIDI) { - - boost::shared_ptr ret (new SMFSource (node)); + + boost::shared_ptr ret (new SMFSource (s, node)); SourceCreated (ret); return ret; @@ -121,35 +128,34 @@ SourceFactory::create (const XMLNode& node) #ifdef HAVE_COREAUDIO boost::shared_ptr -SourceFactory::createReadable (string idstr, AudioFileSource::Flag flags, bool announce) +SourceFactory::createReadable (DataType type, Session& s, string idstr, AudioFileSource::Flag flags, bool announce) { if (type == DataType::AUDIO) { if (flags & Destructive) { - boost::shared_ptr ret (new DestructiveFileSource (idstr, flags)); + boost::shared_ptr ret (new DestructiveFileSource (s, idstr, flags)); if (announce) { SourceCreated (ret); } return ret; - } - - try { - boost::shared_ptr ret (new CoreAudioSource (idstr, flags)); - if (announce) { - SourceCreated (ret); + + try { + boost::shared_ptr ret (new CoreAudioSource (s, idstr, flags)); + if (announce) { + SourceCreated (ret); + } + return ret; + + } catch (failed_constructor& err) { + boost::shared_ptr ret (new SndFileSource (s, idstr, flags)); + if (announce) { + SourceCreated (ret); + } + return ret; } - return ret; - } - catch (failed_constructor& err) { - boost::shared_ptr ret (new SndFileSource (idstr, flags)); - if (announce) { - SourceCreated (ret); - } - return ret; - } } else if (type == DataType::MIDI) { - boost::shared_ptr ret (new SMFSource (node)); + boost::shared_ptr ret (new SMFSource (s, node)); SourceCreated (ret); return ret; @@ -161,10 +167,11 @@ SourceFactory::createReadable (string idstr, AudioFileSource::Flag flags, bool a #else boost::shared_ptr -SourceFactory::createReadable (DataType type, string idstr, AudioFileSource::Flag flags, bool announce) +SourceFactory::createReadable (DataType type, Session& s, string idstr, AudioFileSource::Flag flags, bool announce) { if (type == DataType::AUDIO) { - boost::shared_ptr ret (new SndFileSource (idstr, flags)); + + boost::shared_ptr ret (new SndFileSource (s, idstr, flags)); if (announce) { SourceCreated (ret); } @@ -172,8 +179,10 @@ SourceFactory::createReadable (DataType type, string idstr, AudioFileSource::Fla } else if (type == DataType::MIDI) { - boost::shared_ptr ret (new SMFSource (idstr, SMFSource::Flag(0))); // FIXME: flags? - SourceCreated (ret); + boost::shared_ptr ret (new SMFSource (s, idstr, SMFSource::Flag(0))); // FIXME: flags? + if (announce) { + SourceCreated (ret); + } return ret; } @@ -184,13 +193,14 @@ SourceFactory::createReadable (DataType type, string idstr, AudioFileSource::Fla #endif // HAVE_COREAUDIO boost::shared_ptr -SourceFactory::createWritable (DataType type, std::string path, bool destructive, jack_nframes_t rate, bool announce) +SourceFactory::createWritable (DataType type, Session& s, std::string path, bool destructive, jack_nframes_t rate, bool announce) { /* this might throw failed_constructor(), which is OK */ if (type == DataType::AUDIO) { if (destructive) { - boost::shared_ptr ret (new DestructiveFileSource (path, + + boost::shared_ptr ret (new DestructiveFileSource (s, path, Config->get_native_file_data_format(), Config->get_native_file_header_format(), rate)); @@ -200,7 +210,8 @@ SourceFactory::createWritable (DataType type, std::string path, bool destructive return ret; } else { - boost::shared_ptr ret (new SndFileSource (path, + + boost::shared_ptr ret (new SndFileSource (s, path, Config->get_native_file_data_format(), Config->get_native_file_header_format(), rate)); @@ -208,13 +219,15 @@ SourceFactory::createWritable (DataType type, std::string path, bool destructive SourceCreated (ret); } return ret; + } + } else if (type == DataType::MIDI) { - boost::shared_ptr ret (new SMFSource (path)); + boost::shared_ptr ret (new SMFSource (s, path)); SourceCreated (ret); return ret; - + } return boost::shared_ptr (); -- cgit v1.2.3