Add support for newly introduced class ARDOUR::DSPLoadCalculator (when building with...
[ardour.git] / libs / ardour / audiosource.cc
index 62a632e435096426ab603dd1bdd342b5187ec53f..c79cbbbe26e1b13ef7ba44b29999352fdfc2bc0e 100644 (file)
@@ -50,6 +50,7 @@
 #include <glibmm/fileutils.h>
 #include <glibmm/miscutils.h>
 
+#include "pbd/file_utils.h"
 #include "pbd/scoped_file_descriptor.h"
 #include "pbd/xml++.h"
 
@@ -242,6 +243,16 @@ AudioSource::initialize_peakfile (const string& audio_path)
 
        _peakpath = construct_peak_filepath (audio_path);
 
+       if (!empty() && !Glib::file_test (_peakpath.c_str(), Glib::FILE_TEST_EXISTS)) {
+               string oldpeak = construct_peak_filepath (audio_path, true);
+               DEBUG_TRACE(DEBUG::Peaks, string_compose ("Looking for old peak file %1 for Audio file %2\n", oldpeak, audio_path));
+               if (Glib::file_test (oldpeak.c_str(), Glib::FILE_TEST_EXISTS)) {
+                       // TODO use hard-link if possible
+                       DEBUG_TRACE(DEBUG::Peaks, string_compose ("Copy old peakfile %1 to %2\n", oldpeak, _peakpath));
+                       PBD::copy_file (oldpeak, _peakpath);
+               }
+       }
+
        DEBUG_TRACE(DEBUG::Peaks, string_compose ("Initialize Peakfile %1 for Audio file %2\n", _peakpath, audio_path));
 
        if (g_stat (_peakpath.c_str(), &statbuf)) {