2 Copyright (C) 2000-2006 Paul Davis
4 This program is free software; you can redistribute it and/or modify
5 it under the terms of the GNU General Public License as published by
6 the Free Software Foundation; either version 2 of the License, or
7 (at your option) any later version.
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 #include <ardour/source_factory.h>
22 #include <ardour/sndfilesource.h>
23 #include <ardour/destructive_filesource.h>
24 #include <ardour/configuration.h>
27 #include <ardour/coreaudiosource.h>
32 using namespace ARDOUR;
35 sigc::signal<void,boost::shared_ptr<Source> > SourceFactory::SourceCreated;
38 boost::shared_ptr<Source>
39 SourceFactory::create (Session& s, const XMLNode& node)
41 if (node.property (X_("destructive")) != 0) {
43 boost::shared_ptr<Source> ret (new DestructiveFileSource (s, node));
50 boost::shared_ptr<Source> ret (new CoreAudioSource (s, node));
56 catch (failed_constructor& err) {
57 boost::shared_ptr<Source> ret (new SndFileSource (s, node));
63 return boost::shared_ptr<Source>();
68 boost::shared_ptr<Source>
69 SourceFactory::create (Session& s, const XMLNode& node)
71 if (node.property (X_("destructive")) != 0) {
73 boost::shared_ptr<Source> ret (new DestructiveFileSource (s, node));
79 boost::shared_ptr<Source> ret (new SndFileSource (s, node));
85 #endif // HAVE_COREAUDIO
88 boost::shared_ptr<Source>
89 SourceFactory::createReadable (Session& s, string idstr, AudioFileSource::Flag flags, bool announce)
91 if (flags & Destructive) {
92 boost::shared_ptr<Source> ret (new DestructiveFileSource (s, idstr, flags));
100 boost::shared_ptr<Source> ret (new CoreAudioSource (s, idstr, flags));
107 catch (failed_constructor& err) {
108 boost::shared_ptr<Source> ret (new SndFileSource (s, idstr, flags));
115 return boost::shared_ptr<Source>();
120 boost::shared_ptr<Source>
121 SourceFactory::createReadable (Session& s, string idstr, AudioFileSource::Flag flags, bool announce)
123 boost::shared_ptr<Source> ret (new SndFileSource (s, idstr, flags));
130 #endif // HAVE_COREAUDIO
132 boost::shared_ptr<Source>
133 SourceFactory::createWritable (Session& s, std::string path, bool destructive, nframes_t rate, bool announce)
135 /* this might throw failed_constructor(), which is OK */
138 boost::shared_ptr<Source> ret (new DestructiveFileSource (s, path,
139 Config->get_native_file_data_format(),
140 Config->get_native_file_header_format(),
148 boost::shared_ptr<Source> ret (new SndFileSource (s, path,
149 Config->get_native_file_data_format(),
150 Config->get_native_file_header_format(),