Fix range-separate for musically-locked MIDI regions
[ardour.git] / libs / ardour / audiosource.cc
index e7d81feaec284beb326339cc948f70adce573d69..2db06230f64debce11a8e9295250f8e25d7cbb80 100644 (file)
@@ -58,7 +58,7 @@
 #include "ardour/runtime_functions.h"
 #include "ardour/session.h"
 
-#include "i18n.h"
+#include "pbd/i18n.h"
 
 #include "ardour/debug.h"
 
@@ -133,7 +133,7 @@ AudioSource::get_state ()
        XMLNode& node (Source::get_state());
 
        if (_captured_for.length()) {
-               node.add_property ("captured-for", _captured_for);
+               node.set_property ("captured-for", _captured_for);
        }
 
        return node;
@@ -142,12 +142,7 @@ AudioSource::get_state ()
 int
 AudioSource::set_state (const XMLNode& node, int /*version*/)
 {
-       const XMLProperty* prop;
-
-       if ((prop = node.property ("captured-for")) != 0) {
-               _captured_for = prop->value();
-       }
-
+       node.get_property ("captured-for", _captured_for);
        return 0;
 }
 
@@ -238,6 +233,7 @@ AudioSource::rename_peakfile (string newpath)
 int
 AudioSource::initialize_peakfile (const string& audio_path, const bool in_session)
 {
+       Glib::Threads::Mutex::Lock lm (_initialize_peaks_lock);
        GStatBuf statbuf;
 
        _peakpath = construct_peak_filepath (audio_path, in_session);
@@ -386,7 +382,9 @@ AudioSource::read_peaks_with_fpp (PeakData *peaks, framecnt_t npeaks, framepos_t
 
                if (statbuf.st_size < expected_file_size) {
                        warning << string_compose (_("peak file %1 is truncated from %2 to %3"), _peakpath, expected_file_size, statbuf.st_size) << endmsg;
+                       lm.release(); // build_peaks_from_scratch() takes _lock
                        const_cast<AudioSource*>(this)->build_peaks_from_scratch ();
+                       lm.acquire ();
                        if (g_stat (_peakpath.c_str(), &statbuf) != 0) {
                                error << string_compose (_("Cannot open peakfile @ %1 for size check (%2) after rebuild"), _peakpath, strerror (errno)) << endmsg;
                        }