From d3f9cea1e2839d9e98f5a227efa777562d1f111f Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 4 Dec 2007 16:26:12 +0000 Subject: [PATCH] fix for vanishing waveforms on imported files git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2738 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/audiofilesource.cc | 7 ++--- libs/ardour/audiosource.cc | 52 ++++++++++++++-------------------- libs/ardour/source_factory.cc | 3 +- 3 files changed, 25 insertions(+), 37 deletions(-) diff --git a/libs/ardour/audiofilesource.cc b/libs/ardour/audiofilesource.cc index 7362936826..bcace29978 100644 --- a/libs/ardour/audiofilesource.cc +++ b/libs/ardour/audiofilesource.cc @@ -134,18 +134,15 @@ AudioFileSource::removable () const int AudioFileSource::init (ustring pathstr, bool must_exist) { - bool is_new = false; - _length = 0; timeline_position = 0; _peaks_built = false; - file_is_new = false; - if (!find (pathstr, must_exist, is_new, _channel)) { + if (!find (pathstr, must_exist, file_is_new, _channel)) { throw non_existent_source (); } - if (is_new && must_exist) { + if (file_is_new && must_exist) { return -1; } diff --git a/libs/ardour/audiosource.cc b/libs/ardour/audiosource.cc index 5e4cc763ed..a71c927f62 100644 --- a/libs/ardour/audiosource.cc +++ b/libs/ardour/audiosource.cc @@ -137,7 +137,7 @@ AudioSource::peaks_ready (sigc::slot the_slot, sigc::connection& conn) con /* check to see if the peak data is ready. if not connect the slot while still holding the lock. */ - + if (!(ret = _peaks_built)) { conn = PeaksReady.connect (the_slot); } @@ -194,44 +194,36 @@ AudioSource::initialize_peakfile (bool newfile, ustring audio_path) peakpath = find_broken_peakfile (peakpath, audio_path); } - if (newfile) { - - if (!_build_peakfiles) { - return 0; + if (stat (peakpath.c_str(), &statbuf)) { + if (errno != ENOENT) { + /* it exists in the peaks dir, but there is some kind of error */ + + error << string_compose(_("AudioSource: cannot stat peakfile \"%1\""), peakpath) << endmsg; + return -1; } + /* peakfile does not exist */ + _peaks_built = false; - + } else { - - if (stat (peakpath.c_str(), &statbuf)) { - if (errno != ENOENT) { - /* it exists in the peaks dir, but there is some kind of error */ - - error << string_compose(_("AudioSource: cannot stat peakfile \"%1\""), peakpath) << endmsg; - return -1; - } - + + /* we found it in the peaks dir, so check it out */ + + if (statbuf.st_size == 0) { + // empty _peaks_built = false; - } else { + // Check if the audio file has changed since the peakfile was built. + struct stat stat_file; + int err = stat (audio_path.c_str(), &stat_file); - /* we found it in the peaks dir, so check it out */ - - if (statbuf.st_size == 0) { + if (!err && stat_file.st_mtime > statbuf.st_mtime){ _peaks_built = false; + _peak_byte_max = 0; } else { - // Check if the audio file has changed since the peakfile was built. - struct stat stat_file; - int err = stat (audio_path.c_str(), &stat_file); - - if (!err && stat_file.st_mtime > statbuf.st_mtime){ - _peaks_built = false; - _peak_byte_max = 0; - } else { - _peaks_built = true; - _peak_byte_max = statbuf.st_size; - } + _peaks_built = true; + _peak_byte_max = statbuf.st_size; } } } diff --git a/libs/ardour/source_factory.cc b/libs/ardour/source_factory.cc index cee0173387..30b9ab4d9b 100644 --- a/libs/ardour/source_factory.cc +++ b/libs/ardour/source_factory.cc @@ -64,7 +64,7 @@ peak_thread_work () if (SourceFactory::files_with_peaks.empty()) { goto wait; } - + boost::shared_ptr as (SourceFactory::files_with_peaks.front().lock()); SourceFactory::files_with_peaks.pop_front (); SourceFactory::peak_building_lock.unlock (); @@ -72,7 +72,6 @@ peak_thread_work () if (!as) { continue; } - as->setup_peakfile (); } }