summaryrefslogtreecommitdiff
path: root/libs/ardour/source_factory.cc
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2007-01-09 23:24:54 +0000
committerDavid Robillard <d@drobilla.net>2007-01-09 23:24:54 +0000
commit532f6aad4ac79ca15d69deccd18fca90e444c437 (patch)
tree0d4ca5449af8eb48ad56e163efcab42c4656e8de /libs/ardour/source_factory.cc
parentef6b25432d9c46d71b08c0f7d5f2686df428c4e8 (diff)
Merged with trunk R1283.
NOTE: Compiles, but broken (crash on adding MIDI track). git-svn-id: svn://localhost/ardour2/branches/midi@1292 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/source_factory.cc')
-rw-r--r--libs/ardour/source_factory.cc161
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> ();