fix for vanishing waveforms on imported files

git-svn-id: svn://localhost/ardour2/branches/2.0-ongoing@2738 d708f5d6-7413-0410-9779-e7cbd77b26cf
This commit is contained in:
Paul Davis 2007-12-04 16:26:12 +00:00
parent a49728790b
commit d3f9cea1e2
3 changed files with 25 additions and 37 deletions

View file

@ -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;
}

View file

@ -137,7 +137,7 @@ AudioSource::peaks_ready (sigc::slot<void> 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;
}
}
}

View file

@ -64,7 +64,7 @@ peak_thread_work ()
if (SourceFactory::files_with_peaks.empty()) {
goto wait;
}
boost::shared_ptr<AudioSource> 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 ();
}
}