major fixes to automation editing
[ardour.git] / libs / ardour / destructive_filesource.cc
index e160ffd6089d6de79872d23b496a53b93c2e5d41..2f2e85ed5a088652ad7cd59f3c09de66af79d502 100644 (file)
@@ -55,8 +55,10 @@ typedef off_t off64_t;
 #include <fcntl.h>
 
 #include <pbd/error.h>
+#include <pbd/stacktrace.h>
 #include <ardour/destructive_filesource.h>
 #include <ardour/utils.h>
+#include <ardour/session.h>
 
 #include "i18n.h"
 
@@ -289,7 +291,7 @@ DestructiveFileSource::write_unlocked (Sample* data, nframes_t cnt)
                _capture_end = false;
                
                /* move to the correct location place */
-               file_pos = capture_start_frame;
+               file_pos = capture_start_frame - timeline_position;
                
                // split cnt in half
                nframes_t subcnt = cnt / 2;
@@ -343,17 +345,16 @@ DestructiveFileSource::write_unlocked (Sample* data, nframes_t cnt)
        } else {
 
                /* in the middle of recording */
-               
 
                if (write_float (data, file_pos, cnt) != cnt) {
                        return 0;
                }
        }
-       
+
        old_file_pos = file_pos;
        update_length (file_pos, cnt);
        file_pos += cnt;
-       
+
        if (_build_peakfiles) {
                PeakBuildRecord *pbr = 0;
                
@@ -413,3 +414,11 @@ DestructiveFileSource::set_timeline_position (nframes_t pos)
 {
        //destructive track timeline postion does not change except at instantion or when header_position_offset (session start) changes
 }
+
+int
+DestructiveFileSource::read_peaks (PeakData *peaks, nframes_t npeaks, nframes_t start, nframes_t cnt, double samples_per_unit) const
+{
+       // cerr << _name << " read peaks at " << start << " for " << cnt << " tpos = " << timeline_position << endl;
+       return AudioFileSource::read_peaks (peaks, npeaks, start, cnt, samples_per_unit);
+}
+