Add support for newly introduced class ARDOUR::DSPLoadCalculator (when building with...
[ardour.git] / libs / ardour / audiosource.cc
index 9aea6f1e0e5e51f5639cb948a343c2664f0e62a1..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,14 +243,18 @@ AudioSource::initialize_peakfile (const string& audio_path)
 
        _peakpath = construct_peak_filepath (audio_path);
 
-       DEBUG_TRACE(DEBUG::Peaks, string_compose ("Initialize Peakfile %1 for Audio file %2\n", _peakpath, audio_path));
-
-       /* if the peak file should be there, but isn't .... */
-
        if (!empty() && !Glib::file_test (_peakpath.c_str(), Glib::FILE_TEST_EXISTS)) {
-               _peakpath = find_broken_peakfile (_peakpath, audio_path);
+               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)) {
                if (errno != ENOENT) {
                        /* it exists in the peaks dir, but there is some kind of error */