PluginInfo::type added to copy constructor. But why is the copy constructor defined...
[ardour.git] / libs / ardour / source_factory.cc
index 23a9c29c96ec3ee3d3931b54e43669111af8d9a7..a0d0edc333787a865753404966349e26e602bfe6 100644 (file)
 #include <pbd/error.h>
 #include <pbd/convert.h>
 #include <pbd/pthread_utils.h>
+#include <pbd/stacktrace.h>
 
 #include <ardour/source_factory.h>
 #include <ardour/sndfilesource.h>
 #include <ardour/silentfilesource.h>
 #include <ardour/configuration.h>
 
-#undef USE_COREAUDIO_FOR_FILES
+#ifdef  HAVE_COREAUDIO
+#define USE_COREAUDIO_FOR_FILES
+#endif
 
 #ifdef USE_COREAUDIO_FOR_FILES
 #include <ardour/coreaudiosource.h>
 #endif
 
+
 #include "i18n.h"
 
 using namespace ARDOUR;
@@ -50,7 +54,7 @@ std::list<boost::weak_ptr<AudioSource> > SourceFactory::files_with_peaks;
 static void 
 peak_thread_work ()
 {
-       PBD::ThreadCreated (pthread_self(), string ("peakbuilder-") + to_string (pthread_self(), std::dec));
+       PBD::notify_gui_about_thread_creation (pthread_self(), string ("peakbuilder-") + to_string (pthread_self(), std::dec));
 
        while (true) {
 
@@ -72,6 +76,7 @@ peak_thread_work ()
                if (!as) {
                        continue;
                }
+
                as->setup_peakfile ();
        }
 }
@@ -120,12 +125,11 @@ SourceFactory::createSilent (Session& s, const XMLNode& node, nframes_t nframes,
        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));
+               boost::shared_ptr<Source> ret (new SndFileSource (s, node));
                if (setup_peakfile (ret, defer_peaks)) {
                        return boost::shared_ptr<Source>();
                }
@@ -137,47 +141,34 @@ SourceFactory::create (Session& s, const XMLNode& node, bool defer_peaks)
 
        catch (failed_constructor& err) {       
 
+#ifdef USE_COREAUDIO_FOR_FILES
+
                /* this is allowed to throw */
 
-               boost::shared_ptr<Source> ret (new SndFileSource (s, node));
+               boost::shared_ptr<Source> ret (new CoreAudioSource (s, node));
                if (setup_peakfile (ret, defer_peaks)) {
                        return boost::shared_ptr<Source>();
                }
                ret->check_for_analysis_data_on_disk ();
                SourceCreated (ret);
                return ret;
-       }
-
-       return boost::shared_ptr<Source>();
-}
-
 #else
+               throw; // rethrow 
+#endif
 
-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 SndFileSource (s, node));
-       
-       if (setup_peakfile (ret, defer_peaks)) {
-               return boost::shared_ptr<Source>();
        }
-       ret->check_for_analysis_data_on_disk ();
-       SourceCreated (ret);
-       return ret;
-}
 
-#endif // USE_COREAUDIO_FOR_FILES
+       return boost::shared_ptr<Source>(); // keep stupid gcc happy
+}
 
-#ifdef USE_COREAUDIO_FOR_FILES
 boost::shared_ptr<Source>
 SourceFactory::createReadable (Session& s, string path, int chn, AudioFileSource::Flag flags, bool announce, bool defer_peaks)
 {
        if (!(flags & Destructive)) {
 
                try {
-                       boost::shared_ptr<Source> ret (new CoreAudioSource (s, path, chn, flags));
+
+                       boost::shared_ptr<Source> ret (new SndFileSource (s, path, chn, flags));
                        if (setup_peakfile (ret, defer_peaks)) {
                                return boost::shared_ptr<Source>();
                        }
@@ -192,7 +183,9 @@ SourceFactory::createReadable (Session& s, string path, int chn, AudioFileSource
 
                        /* this is allowed to throw */
 
-                       boost::shared_ptr<Source> ret (new SndFileSource (s, path, chn, flags));
+#ifdef USE_COREAUDIO_FOR_FILES
+
+                       boost::shared_ptr<Source> ret (new CoreAudioSource (s, path, chn, flags));
                        if (setup_peakfile (ret, defer_peaks)) {
                                return boost::shared_ptr<Source>();
                        }
@@ -201,46 +194,19 @@ SourceFactory::createReadable (Session& s, string path, int chn, AudioFileSource
                                SourceCreated (ret);
                        }
                        return ret;
+
+#else
+                       throw; // rethrow
+#endif
                }
 
        } else {
 
-               boost::shared_ptr<Source> ret (new SndFileSource (s, path, chn, flags));
-               if (setup_peakfile (ret, defer_peaks)) {
-                       return boost::shared_ptr<Source>();
-               }
-               ret->check_for_analysis_data_on_disk ();
-               if (announce) {
-                       SourceCreated (ret);
-               }
-               return ret;
        }
 
        return boost::shared_ptr<Source>();
 }
 
-#else
-
-boost::shared_ptr<Source>
-SourceFactory::createReadable (Session& s, string path, int chn, AudioFileSource::Flag flags, bool announce, bool defer_peaks)
-{
-       boost::shared_ptr<Source> ret (new SndFileSource (s, path, chn, flags));
-
-       if (setup_peakfile (ret, defer_peaks)) {
-               return boost::shared_ptr<Source>();
-       }
-
-       ret->check_for_analysis_data_on_disk ();
-
-       if (announce) {
-               SourceCreated (ret);
-       }
-
-       return ret;
-}
-
-#endif // USE_COREAUDIO_FOR_FILES
-
 boost::shared_ptr<Source>
 SourceFactory::createWritable (Session& s, std::string path, bool destructive, nframes_t rate, bool announce, bool defer_peaks)
 {