Fixes case where audiofiles used wrong peakfiles
This commit is contained in:
parent
95b144ee58
commit
624f76b229
@ -37,7 +37,7 @@ public:
|
||||
virtual ~AudioPlaylistSource ();
|
||||
|
||||
bool empty() const;
|
||||
std::string generate_peak_path (const std::string& audio_path);
|
||||
std::string construct_peak_filepath (const std::string& audio_path) const;
|
||||
uint32_t n_channels() const;
|
||||
bool clamped_at_unity () const { return false; }
|
||||
|
||||
|
@ -39,7 +39,7 @@ class LIBARDOUR_API AudioFileSource : public AudioSource, public FileSource {
|
||||
public:
|
||||
virtual ~AudioFileSource ();
|
||||
|
||||
std::string generate_peak_path (const std::string& audio_path);
|
||||
std::string construct_peak_filepath (const std::string& audio_filepath) const;
|
||||
std::string find_broken_peakfile (const std::string& missing_peak_path,
|
||||
const std::string& audio_path);
|
||||
|
||||
|
@ -136,9 +136,9 @@ 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 generate_peak_path(const std::string& audio_path) = 0;
|
||||
virtual std::string construct_peak_filepath(const std::string& audio_filepath) const = 0;
|
||||
virtual std::string find_broken_peakfile (std::string /* missing_peak_path */,
|
||||
std::string audio_path) { return generate_peak_path (audio_path); }
|
||||
std::string audio_path) { return construct_peak_filepath (audio_path); }
|
||||
|
||||
virtual int read_peaks_with_fpp (PeakData *peaks,
|
||||
framecnt_t npeaks, framepos_t start, framecnt_t cnt,
|
||||
|
@ -198,7 +198,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 peak_path (const std::string&) const;
|
||||
std::string construct_peak_filepath (const std::string&) 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);
|
||||
|
@ -217,7 +217,7 @@ AudioPlaylistSource::setup_peakfile ()
|
||||
}
|
||||
|
||||
string
|
||||
AudioPlaylistSource::generate_peak_path (const string& /*audio_path_IGNORED*/)
|
||||
AudioPlaylistSource::construct_peak_filepath (const string& /*audio_path_IGNORED*/) const
|
||||
{
|
||||
return _peak_path;
|
||||
}
|
||||
|
@ -164,26 +164,9 @@ AudioFileSource::init (const string& pathstr, bool must_exist)
|
||||
}
|
||||
|
||||
string
|
||||
AudioFileSource::generate_peak_path (const string& audio_path)
|
||||
AudioFileSource::construct_peak_filepath (const string& audio_path) const
|
||||
{
|
||||
string base;
|
||||
|
||||
string::size_type suffix = audio_path.find_last_of ('.');
|
||||
|
||||
if (suffix != string::npos) {
|
||||
base = audio_path.substr (0, suffix);
|
||||
} else {
|
||||
warning << string_compose (_("Odd audio file path: %1"), audio_path) << endmsg;
|
||||
base = audio_path;
|
||||
}
|
||||
|
||||
base += '%';
|
||||
base += (char) ('A' + _channel);
|
||||
|
||||
/* pass in the name/path of the source, with no audio file type suffix
|
||||
*/
|
||||
|
||||
return _session.peak_path (base);
|
||||
return _session.construct_peak_filepath (audio_path);
|
||||
}
|
||||
|
||||
string
|
||||
@ -230,7 +213,7 @@ AudioFileSource::find_broken_peakfile (const string& peak_path, const string& au
|
||||
string
|
||||
AudioFileSource::broken_peak_path (const string& audio_path)
|
||||
{
|
||||
return _session.peak_path (basename_nosuffix (audio_path));
|
||||
return _session.construct_peak_filepath (basename_nosuffix (audio_path));
|
||||
}
|
||||
|
||||
string
|
||||
|
@ -239,7 +239,7 @@ AudioSource::initialize_peakfile (const string& audio_path)
|
||||
{
|
||||
GStatBuf statbuf;
|
||||
|
||||
_peakpath = generate_peak_path (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));
|
||||
|
||||
|
@ -58,7 +58,7 @@ FileSource::FileSource (Session& session, DataType type, const string& path, con
|
||||
, _path (path)
|
||||
, _file_is_new (!origin.empty()) // if origin is left unspecified (empty string) then file must exist
|
||||
, _channel (0)
|
||||
, _origin (origin)
|
||||
, _origin (origin)
|
||||
{
|
||||
set_within_session_from_path (path);
|
||||
}
|
||||
@ -148,9 +148,9 @@ FileSource::set_state (const XMLNode& node, int /*version*/)
|
||||
_channel = 0;
|
||||
}
|
||||
|
||||
if ((prop = node.property (X_("origin"))) != 0) {
|
||||
_origin = prop->value();
|
||||
}
|
||||
if ((prop = node.property (X_("origin"))) != 0) {
|
||||
_origin = prop->value();
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -107,6 +107,8 @@
|
||||
|
||||
#include "i18n.h"
|
||||
|
||||
#include <glibmm/checksum.h>
|
||||
|
||||
namespace ARDOUR {
|
||||
class MidiSource;
|
||||
class Processor;
|
||||
@ -4362,19 +4364,20 @@ Session::count_sources_by_origin (const string& path)
|
||||
}
|
||||
|
||||
string
|
||||
Session::peak_path (const string& base) const
|
||||
Session::construct_peak_filepath (const string& filepath) const
|
||||
{
|
||||
if (Glib::path_is_absolute (base)) {
|
||||
string interchange_dir_string = string (interchange_dir_name) + G_DIR_SEPARATOR;
|
||||
|
||||
if (Glib::path_is_absolute (filepath)) {
|
||||
|
||||
/* rip the session dir from the audiofile source */
|
||||
|
||||
string session_path;
|
||||
string interchange_dir_string = string (interchange_dir_name) + G_DIR_SEPARATOR;
|
||||
bool in_another_session = true;
|
||||
|
||||
if (base.find (interchange_dir_string) != string::npos) {
|
||||
if (filepath.find (interchange_dir_string) != string::npos) {
|
||||
|
||||
session_path = Glib::path_get_dirname (base); /* now ends in audiofiles */
|
||||
session_path = Glib::path_get_dirname (filepath); /* now ends in audiofiles */
|
||||
session_path = Glib::path_get_dirname (session_path); /* now ends in session name */
|
||||
session_path = Glib::path_get_dirname (session_path); /* now ends in interchange */
|
||||
session_path = Glib::path_get_dirname (session_path); /* now has session path */
|
||||
@ -4394,12 +4397,32 @@ Session::peak_path (const string& base) const
|
||||
|
||||
if (in_another_session) {
|
||||
SessionDirectory sd (session_path);
|
||||
return Glib::build_filename (sd.peak_path(), Glib::path_get_basename (base) + peakfile_suffix);
|
||||
return Glib::build_filename (sd.peak_path(), Glib::path_get_basename (filepath) + peakfile_suffix);
|
||||
}
|
||||
}
|
||||
|
||||
std::string basename = Glib::path_get_basename (base);
|
||||
return Glib::build_filename (_session_dir->peak_path(), basename + peakfile_suffix);
|
||||
std::string filename = Glib::path_get_basename (filepath);
|
||||
std::string path;
|
||||
/* file is within our session: just use the filename for checksumming and leave path empty */
|
||||
|
||||
if (filepath.find (interchange_dir_string) == string::npos) {
|
||||
/* the file is outside our session: add the filepath for checksummming */
|
||||
path = Glib::path_get_dirname (filepath);
|
||||
}
|
||||
|
||||
string::size_type suffix = filename.find_last_of ('.');
|
||||
|
||||
std::string filename_unsuffixed;
|
||||
if (suffix != string::npos) {
|
||||
filename_unsuffixed = filename.substr (0, suffix);
|
||||
} else {
|
||||
warning << string_compose (_("Odd audio file path: %1"), filepath) << endmsg;
|
||||
filename_unsuffixed = filename;
|
||||
}
|
||||
|
||||
std::string checksum = "_" + Glib::Checksum::compute_checksum(Glib::Checksum::CHECKSUM_MD5, path + G_DIR_SEPARATOR + filename);
|
||||
|
||||
return Glib::build_filename (_session_dir->peak_path(), filename_unsuffixed + checksum + peakfile_suffix);
|
||||
}
|
||||
|
||||
string
|
||||
|
@ -3052,7 +3052,7 @@ Session::cleanup_sources (CleanupReport& rep)
|
||||
or for the first channel of embedded files. it will miss
|
||||
some peakfiles for other channels
|
||||
*/
|
||||
string peakpath = peak_path (base);
|
||||
string peakpath = construct_peak_filepath (base);
|
||||
|
||||
if (Glib::file_test (peakpath.c_str(), Glib::FILE_TEST_EXISTS)) {
|
||||
if (::g_unlink (peakpath.c_str()) != 0) {
|
||||
|
Loading…
Reference in New Issue
Block a user