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>
28 using namespace ARDOUR;
31 sigc::signal<void,boost::shared_ptr<Source> > SourceFactory::SourceCreated;
36 boost::shared_ptr<Source>
37 SourceFactory::create (const XMLNode& node)
39 if (node.property (X_("destructive")) != 0) {
41 boost::shared_ptr<Source> ret (new DestructiveFileSource (node));
48 boost::shared_ptr<Source> ret (new CoreAudioSource (node));
54 catch (failed_constructor& err) {
55 boost::shared_ptr<Source> ret (new SndFileSource (node));
61 return boost::shared_ptr<Source>();
66 boost::shared_ptr<Source>
67 SourceFactory::create (const XMLNode& node)
69 if (node.property (X_("destructive")) != 0) {
71 boost::shared_ptr<Source> ret (new DestructiveFileSource (node));
77 boost::shared_ptr<Source> ret (new SndFileSource (node));
83 #endif // HAVE_COREAUDIO
86 boost::shared_ptr<Source>
87 SourceFactory::createReadable (string idstr, AudioFileSource::Flag flags, bool announce)
89 if (flags & Destructive) {
90 boost::shared_ptr<Source> ret (new DestructiveFileSource (idstr, flags));
98 boost::shared_ptr<Source> ret (new CoreAudioSource (idstr, flags));
105 catch (failed_constructor& err) {
106 boost::shared_ptr<Source> ret (new SndFileSource (idstr, flags));
113 return boost::shared_ptr<Source>();
118 boost::shared_ptr<Source>
119 SourceFactory::createReadable (string idstr, AudioFileSource::Flag flags, bool announce)
121 boost::shared_ptr<Source> ret (new SndFileSource (idstr, flags));
128 #endif // HAVE_COREAUDIO
130 boost::shared_ptr<Source>
131 SourceFactory::createWritable (std::string path, bool destructive, jack_nframes_t rate, bool announce)
133 /* this might throw failed_constructor(), which is OK */
136 boost::shared_ptr<Source> ret (new DestructiveFileSource (path,
137 Config->get_native_file_data_format(),
138 Config->get_native_file_header_format(),
146 boost::shared_ptr<Source> ret (new SndFileSource (path,
147 Config->get_native_file_data_format(),
148 Config->get_native_file_header_format(),