Add a dedicated export method to MidiRegion
[ardour.git] / libs / ardour / source.cc
index c9d5bb243e90b48186af17b7f5dc5b15137a7eb8..f9772ec9eddbd4c2210c486e2b1581ac91ba7bad 100644 (file)
@@ -40,7 +40,7 @@
 #include "ardour/source.h"
 #include "ardour/transient_detector.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 using namespace std;
 using namespace ARDOUR;
@@ -113,7 +113,7 @@ Source::get_state ()
 int
 Source::set_state (const XMLNode& node, int version)
 {
-       const XMLProperty* prop;
+       XMLProperty const * prop;
 
        if ((prop = node.property ("name")) != 0) {
                _name = prop->value();
@@ -173,20 +173,22 @@ Source::has_been_analysed() const
 void
 Source::set_been_analysed (bool yn)
 {
-       {
+       if (yn) {
+               if (0 == load_transients (get_transients_path())) {
+                       yn = false;
+               }
+       }
+       if (yn != _analysed) {
                Glib::Threads::Mutex::Lock lm (_analysis_lock);
                _analysed = yn;
        }
-
-       if (yn) {
-               load_transients (get_transients_path());
-               AnalysisChanged(); // EMIT SIGNAL
-       }
+       AnalysisChanged(); // EMIT SIGNAL
 }
 
 int
 Source::load_transients (const string& path)
 {
+       int rv = 0;
        FILE *tf;
        if (! (tf = g_fopen (path.c_str (), "rb"))) {
                return -1;
@@ -196,6 +198,7 @@ Source::load_transients (const string& path)
        while (!feof (tf) && !ferror(tf)) {
                double val;
                if (1 != fscanf (tf, "%lf", &val)) {
+                       rv = -1;
                        break;
                }
 
@@ -204,6 +207,7 @@ Source::load_transients (const string& path)
        }
 
        ::fclose (tf);
+       return rv;
 }
 
 string