return ret;
}
-#ifdef USE_COREAUDIO_FOR_FILES
boost::shared_ptr<Source>
SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks)
{
- try {
- boost::shared_ptr<Source> ret (new CoreAudioSource (s, node));
- if (!defer_peaks) {
- if (setup_peakfile (ret, false)) {
- return boost::shared_ptr<Source>();
- }
- }
- SourceCreated (ret);
- return ret;
- }
-
-
- catch (failed_constructor& err) {
+ DataType type = DataType::AUDIO;
+ const XMLProperty* prop = node.property("type");
- /* this is allowed to throw */
+ if (prop) {
+ type = DataType(prop->value());
+ }
- boost::shared_ptr<Source> ret (new SndFileSource (s, node));
- if (!defer_peaks) {
- if (setup_peakfile (ret, false)) {
- return boost::shared_ptr<Source>();
- }
- }
- SourceCreated (ret);
- return ret;
- }
+ if (type == DataType::AUDIO) {
- return boost::shared_ptr<Source>();
-}
+#ifdef HAVE_COREAUDIO
+ try {
+ boost::shared_ptr<Source> ret (new CoreAudioSource (s, node));
+
+ if (setup_peakfile (ret, defer_peaks)) {
+ return boost::shared_ptr<Source>();
+ }
+
+ SourceCreated (ret);
+ return ret;
+ }
+
+
+ catch (failed_constructor& err) {
+
+ /* this is allowed to throw */
+
+ boost::shared_ptr<Source> ret (new SndFileSource (s, node));
+
+ if (setup_peakfile (ret, defer_peaks)) {
+ return boost::shared_ptr<Source>();
+ }
+
+ SourceCreated (ret);
+ return ret;
+ }
#else
+ /* this is allowed to throw */
+
+ boost::shared_ptr<Source> ret (new SndFileSource (s, node));
+
+ if (setup_peakfile (ret, defer_peaks)) {
+ return boost::shared_ptr<Source>();
+ }
+
+ SourceCreated (ret);
+ return ret;
+#endif
+
+ } else if (type == DataType::MIDI) {
-boost::shared_ptr<Source>
-SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks)
-{
- /* this is allowed to throw */
+ boost::shared_ptr<Source> ret (new SMFSource (s, node));
+ }
- boost::shared_ptr<Source> ret (new SndFileSource (s, node));
-
- if (!defer_peaks) {
- if (setup_peakfile (ret, false)) {
- return boost::shared_ptr<Source>();
- }
- }
-
- SourceCreated (ret);
- return ret;
+ return boost::shared_ptr<Source>();
}
-#endif // USE_COREAUDIO_FOR_FILES
-
boost::shared_ptr<Source>
SourceFactory::createReadable (DataType type, Session& s, string path, int chn, AudioFileSource::Flag flags, bool announce, bool defer_peaks)
{
#ifdef HAVE_COREAUDIO
try {
boost::shared_ptr<Source> ret (new CoreAudioSource (s, path, chn, flags));
- if (!defer_peaks) {
- if (setup_peakfile (ret, false)) {
- return boost::shared_ptr<Source>();
- }
+
+ if (setup_peakfile (ret, defer_peaks)) {
+ return boost::shared_ptr<Source>();
}
+
if (announce) {
SourceCreated (ret);
}
catch (failed_constructor& err) {
boost::shared_ptr<Source> ret (new SndFileSource (s, path, chn, flags));
- if (!defer_peaks) {
- if (setup_peakfile (ret, false)) {
- return boost::shared_ptr<Source>();
- }
+ if (setup_peakfile (ret, defer_peaks)) {
+ return boost::shared_ptr<Source>();
}
if (announce) {
SourceCreated (ret);
#else
boost::shared_ptr<Source> ret (new SndFileSource (s, path, chn, flags));
- if (!defer_peaks) {
- if (setup_peakfile (ret, false)) {
- return boost::shared_ptr<Source>();
- }
+ if (setup_peakfile (ret, defer_peaks)) {
+ return boost::shared_ptr<Source>();
}
if (announce) {
(destructive ? AudioFileSource::Flag (SndFileSource::default_writable_flags | AudioFileSource::Destructive) :
SndFileSource::default_writable_flags)));
- if (!defer_peaks) {
- if (setup_peakfile (ret, false)) {
- return boost::shared_ptr<Source>();
- }
+ if (setup_peakfile (ret, false)) {
+ return boost::shared_ptr<Source>();
}
+
if (announce) {
SourceCreated (ret);
}