diff options
author | David Robillard <d@drobilla.net> | 2008-02-16 22:55:47 +0000 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2008-02-16 22:55:47 +0000 |
commit | 859e9106e72a7908fa093d946111d148223225a0 (patch) | |
tree | ec47825b5f5746bcbc5d321d40da7fc798f5c380 /libs/ardour/audiosource.cc | |
parent | 8aa9508c82f32efcf9c7c00e2c9e76268d4dddce (diff) |
Merge with 2.0-ongoing R3071.
git-svn-id: svn://localhost/ardour2/branches/3.0@3074 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/audiosource.cc')
-rw-r--r-- | libs/ardour/audiosource.cc | 19 |
1 files changed, 15 insertions, 4 deletions
diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index cd71dd21e4..01dea08d3e 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -70,6 +70,7 @@ AudioSource::AudioSource (Session& s, ustring name) AudioSource::AudioSource (Session& s, const XMLNode& node) : Source (s, node) { + _peaks_built = false; _peak_byte_max = 0; peakfile = -1; @@ -213,7 +214,7 @@ AudioSource::initialize_peakfile (bool newfile, ustring audio_path) /* we found it in the peaks dir, so check it out */ - if (statbuf.st_size == 0) { + if (statbuf.st_size == 0 || (statbuf.st_size < ((length() / _FPP) * sizeof (PeakData)))) { // empty _peaks_built = false; } else { @@ -221,12 +222,22 @@ AudioSource::initialize_peakfile (bool newfile, ustring audio_path) struct stat stat_file; int err = stat (audio_path.c_str(), &stat_file); - if (!err && stat_file.st_mtime > statbuf.st_mtime){ + if (err) { _peaks_built = false; _peak_byte_max = 0; } else { - _peaks_built = true; - _peak_byte_max = statbuf.st_size; + + /* allow 6 seconds slop on checking peak vs. file times because of various + disk action "races" + */ + + if (stat_file.st_mtime > statbuf.st_mtime && (stat_file.st_mtime - statbuf.st_mtime > 6)) { + _peaks_built = false; + _peak_byte_max = 0; + } else { + _peaks_built = true; + _peak_byte_max = statbuf.st_size; + } } } } |