summaryrefslogtreecommitdiff
path: root/libs/ardour/source.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2006-03-14 03:43:54 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2006-03-14 03:43:54 +0000
commitaf707897735a34ab1a82c7307dc61b12c14027a9 (patch)
treeb2a9fc621c4a5d7865a46f09eb5cafeee959a9a1 /libs/ardour/source.cc
parent1a52aeb370c9fabbd2229da793aee0399f04ca2f (diff)
improvements (!) to waveform display for destructive tracks, plus a generic fix that avoid waveview attemting to read peaks before they are ready
git-svn-id: svn://localhost/trunk/ardour2@388 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/source.cc')
-rw-r--r--libs/ardour/source.cc23
1 files changed, 20 insertions, 3 deletions
diff --git a/libs/ardour/source.cc b/libs/ardour/source.cc
index 2a6337d441..fb09293fd5 100644
--- a/libs/ardour/source.cc
+++ b/libs/ardour/source.cc
@@ -545,19 +545,21 @@ Source::read_peaks (PeakData *peaks, jack_nframes_t npeaks, jack_nframes_t start
tnp = min ((_length/frames_per_peak - current_stored_peak), (jack_nframes_t) expected_peaks);
to_read = min (chunksize, tnp);
+ off_t fend = lseek (peakfile, 0, SEEK_END);
+
if ((nread = ::pread (peakfile, staging, sizeof (PeakData) * to_read, start_byte))
!= sizeof (PeakData) * to_read) {
cerr << "Source["
<< _name
<< "]: cannot read peak data from peakfile ("
- << nread
+ << (nread / sizeof(PeakData))
<< " peaks instead of "
<< to_read
<< ") ("
<< strerror (errno)
<< ')'
<< " at start_byte = " << start_byte
- << " _length = " << _length
+ << " _length = " << _length << " versus len = " << fend
<< " expected maxpeaks = " << (_length - current_frame)/frames_per_peak
<< " npeaks was " << npeaks
<< endl;
@@ -699,7 +701,7 @@ Source::build_peaks ()
}
#ifdef DEBUG_PEAK_BUILD
- cerr << "build peaks with " << pending_peak_builds.size() << " requests pending\n";
+ cerr << "build peaks with " << copy.size() << " requests pending\n";
#endif
for (list<PeakBuildRecord *>::iterator i = copy.begin(); i != copy.end(); ++i) {
@@ -732,6 +734,7 @@ Source::build_peaks ()
}
if (pr_signal) {
+ off_t fend = lseek (peakfile, 0, SEEK_END);
PeaksReady (); /* EMIT SIGNAL */
}
}
@@ -849,3 +852,17 @@ Source::release ()
{
if (_use_cnt) --_use_cnt;
}
+
+jack_nframes_t
+Source::available_peaks (double zoom_factor) const
+{
+ if (zoom_factor < frames_per_peak) {
+ return length(); // peak data will come from the audio file
+ }
+
+ /* peak data comes from peakfile */
+
+ LockMonitor lm (_lock, __LINE__, __FILE__);
+ off_t end = lseek (peakfile, 0, SEEK_END);
+ return (end/sizeof(PeakData)) * frames_per_peak;
+}