use FileSource::within_session() for peak-files
authorRobin Gareus <robin@gareus.org>
Thu, 10 Sep 2015 14:39:35 +0000 (16:39 +0200)
committerRobin Gareus <robin@gareus.org>
Thu, 10 Sep 2015 14:47:26 +0000 (16:47 +0200)
libs/ardour/ardour/audio_playlist_source.h
libs/ardour/ardour/audiofilesource.h
libs/ardour/ardour/audiosource.h
libs/ardour/ardour/session.h
libs/ardour/audio_playlist_source.cc
libs/ardour/audiofilesource.cc
libs/ardour/audiosource.cc
libs/ardour/session.cc

index a11749f46c78bf337b5b23ea0d8bd196307ccb73..9c815fb238cdb1ab5618647ca636d29771c3c024 100644 (file)
@@ -37,7 +37,7 @@ public:
        virtual ~AudioPlaylistSource ();
 
        bool empty() const;
-       std::string construct_peak_filepath (const std::string& audio_path, bool oldformat = false) const;
+       std::string construct_peak_filepath (const std::string& audio_path, const bool in_session = false, const bool old_peak_name = false) const;
        uint32_t   n_channels() const;
        bool clamped_at_unity () const { return false; }
 
index 786d1628e8fc34dad9adb148a59bc8ccd0c05e84..bad6203bc2609cbeb8b8ea579d45bd7590af4ff3 100644 (file)
@@ -39,7 +39,7 @@ class LIBARDOUR_API AudioFileSource : public AudioSource, public FileSource {
 public:
        virtual ~AudioFileSource ();
 
-       std::string construct_peak_filepath (const std::string& audio_filepath, bool oldformat = false) const;
+       std::string construct_peak_filepath (const std::string& audio_path, const bool in_session = false, const bool old_peak_name = false) const;
 
        static void set_peak_dir (const std::string& dir) { peak_dir = dir; }
 
index ad56c8834f48676cee837bd1dc1c3a70e9dcaff0..ad7884e4f42ea74c33a8cf390bd1a687435f90cb 100644 (file)
@@ -126,7 +126,7 @@ class LIBARDOUR_API AudioSource : virtual public Source,
        std::string         _peakpath;
        std::string        _captured_for;
 
-       int initialize_peakfile (const std::string& path);
+       int initialize_peakfile (const std::string& path, const bool in_session = false);
        int build_peaks_from_scratch ();
        int compute_and_write_peaks (Sample* buf, framecnt_t first_frame, framecnt_t cnt,
        bool force, bool intermediate_peaks_ready_signal);
@@ -136,7 +136,7 @@ class LIBARDOUR_API AudioSource : virtual public Source,
 
        virtual framecnt_t read_unlocked (Sample *dst, framepos_t start, framecnt_t cnt) const = 0;
        virtual framecnt_t write_unlocked (Sample *dst, framecnt_t cnt) = 0;
-       virtual std::string construct_peak_filepath(const std::string& audio_filepath, bool oldformat = false) const = 0;
+       virtual std::string construct_peak_filepath (const std::string& audio_path, const bool in_session = false, const bool old_peak_name = false) const = 0;
 
        virtual int read_peaks_with_fpp (PeakData *peaks,
                                         framecnt_t npeaks, framepos_t start, framecnt_t cnt,
index 51d3798d1c6fd7ad2994f3ae761d019008161919..79eb2162da7a50d9a2ee102b76019beceb1c0a7a 100644 (file)
@@ -210,7 +210,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
        std::string plugins_dir () const;     ///< Plugin state
        std::string externals_dir () const;   ///< Links to external files
 
-       std::string construct_peak_filepath (const std::string&, bool oldformat = false) const;
+       std::string construct_peak_filepath (const std::string& audio_path, const bool in_session = false, const bool old_peak_name = false) const;
 
        bool audio_source_name_is_unique (const std::string& name);
        std::string format_audio_source_name (const std::string& legalized_base, uint32_t nchan, uint32_t chan, bool destructive, bool take_required, uint32_t cnt, bool related_exists);
index e9925852b8a62fe848a6cccc163b1749b3387613..8effdd0c808145f866056338f1ea02e203e01f41 100644 (file)
@@ -217,7 +217,7 @@ AudioPlaylistSource::setup_peakfile ()
 }
 
 string
-AudioPlaylistSource::construct_peak_filepath (const string& /*audio_path_IGNORED*/, bool /* oldformat IGNORED*/) const
+AudioPlaylistSource::construct_peak_filepath (const string& /*audio_path_*/, const bool /* in_session */, const bool /* old_peak_name */) const
 {
        return _peak_path;
 }
index 0c921dae8d0c12952168c3986f0b748a611b79fc..ed189152e5fcac46d972ba72dbe2cf3572a7ca50 100644 (file)
@@ -164,17 +164,17 @@ AudioFileSource::init (const string& pathstr, bool must_exist)
 }
 
 string
-AudioFileSource::construct_peak_filepath (const string& audio_path, bool oldformat) const
+AudioFileSource::construct_peak_filepath (const string& audio_path, const bool in_session, const bool old_peak_name) const
 {
        string base;
-       if (oldformat) {
+       if (old_peak_name) {
                base = audio_path.substr (0, audio_path.find_last_of ('.'));
        } else {
                base = audio_path;
        }
        base += '%';
        base += (char) ('A' + _channel);
-       return _session.construct_peak_filepath (base, oldformat);
+       return _session.construct_peak_filepath (base, in_session, old_peak_name);
 }
 
 bool
@@ -270,7 +270,7 @@ AudioFileSource::setup_peakfile ()
                return 0;
        }
        if (!(_flags & NoPeakFile)) {
-               return initialize_peakfile (_path);
+               return initialize_peakfile (_path, within_session());
        } else {
                return 0;
        }
index c79cbbbe26e1b13ef7ba44b29999352fdfc2bc0e..4439669c4f0aa0aba7dd79400e7fc8c45d2282bb 100644 (file)
@@ -237,14 +237,14 @@ AudioSource::rename_peakfile (string newpath)
 }
 
 int
-AudioSource::initialize_peakfile (const string& audio_path)
+AudioSource::initialize_peakfile (const string& audio_path, const bool in_session)
 {
        GStatBuf statbuf;
 
-       _peakpath = construct_peak_filepath (audio_path);
+       _peakpath = construct_peak_filepath (audio_path, in_session);
 
        if (!empty() && !Glib::file_test (_peakpath.c_str(), Glib::FILE_TEST_EXISTS)) {
-               string oldpeak = construct_peak_filepath (audio_path, true);
+               string oldpeak = construct_peak_filepath (audio_path, in_session, 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
index 30ab5e1660cfe353f5c243a7e1942139480e2768..91578c9b179f6dfdad81600549bb86a7ef46e45e 100644 (file)
@@ -4374,7 +4374,7 @@ peak_file_helper (const string& peak_path, const string& file_path, const string
 }
 
 string
-Session::construct_peak_filepath (const string& filepath, bool oldformat) const
+Session::construct_peak_filepath (const string& filepath, const bool in_session, const bool old_peak_name) const
 {
        string interchange_dir_string = string (interchange_dir_name) + G_DIR_SEPARATOR;
 
@@ -4407,7 +4407,7 @@ Session::construct_peak_filepath (const string& filepath, bool oldformat) const
 
                if (in_another_session) {
                        SessionDirectory sd (session_path);
-                       return peak_file_helper (sd.peak_path(), "", Glib::path_get_basename (filepath), !oldformat);
+                       return peak_file_helper (sd.peak_path(), "", Glib::path_get_basename (filepath), !old_peak_name);
                }
        }
 
@@ -4421,11 +4421,11 @@ Session::construct_peak_filepath (const string& filepath, bool oldformat) const
 
        /* 2) if the file is outside our session dir:
         * (imported but not copied) add the path for check-summming */
-       if (filepath.find (interchange_dir_string) == string::npos) {
+       if (!in_session) {
                path = Glib::path_get_dirname (filepath);
        }
        
-       return peak_file_helper (_session_dir->peak_path(), path, Glib::path_get_basename (filepath), !oldformat);
+       return peak_file_helper (_session_dir->peak_path(), path, Glib::path_get_basename (filepath), !old_peak_name);
 }
 
 string