Fix previous patch a bit better.
authorCarl Hetherington <carl@carlh.net>
Fri, 25 Feb 2011 17:40:19 +0000 (17:40 +0000)
committerCarl Hetherington <carl@carlh.net>
Fri, 25 Feb 2011 17:40:19 +0000 (17:40 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@8959 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/ardour/audio_diskstream.h
libs/ardour/ardour/diskstream.h
libs/ardour/audio_diskstream.cc
libs/ardour/diskstream.cc
libs/ardour/midi_diskstream.cc

index ff0a1c2a69df9ac822b4c56bbbb3172e05eeb82d..2bd44d62a6e3f2c6299e539ac3c4ab8d36eb4a3b 100644 (file)
@@ -284,7 +284,6 @@ class AudioDiskstream : public Diskstream
        int add_channel_to (boost::shared_ptr<ChannelList>, uint32_t how_many);
        int remove_channel_from (boost::shared_ptr<ChannelList>, uint32_t how_many);
 
-       framecnt_t playback_distance;
 };
 
 } // namespace ARDOUR
index e81d8a1fd11fc05187f62cc3931920631f300e90..cd5932b3e526de7128e48aed39797817f92da9db 100644 (file)
@@ -288,6 +288,7 @@ class Diskstream : public SessionObject, public PublicDiskstream
 
        framepos_t     file_frame;
        framepos_t     playback_sample;
+       framecnt_t     playback_distance;
 
        uint32_t     _read_data_count;
        uint32_t     _write_data_count;
index a4c6ec178ce0c2acb8e0b0f9705cae0760914eba..8a161c3977b2380b447066ed3c934c4b403b8419 100644 (file)
@@ -76,7 +76,6 @@ AudioDiskstream::AudioDiskstream (Session &sess, const string &name, Diskstream:
        : Diskstream(sess, name, flag)
        , deprecated_io_node(NULL)
        , channels (new ChannelList)
-        , playback_distance (0)
 {
        /* prevent any write sources from being created */
 
@@ -89,7 +88,6 @@ AudioDiskstream::AudioDiskstream (Session& sess, const XMLNode& node)
        : Diskstream(sess, node)
        , deprecated_io_node(NULL)
        , channels (new ChannelList)
-        , playback_distance (0)
 {
        in_set_state = true;
        init ();
index 8720ea6d86dcd187f99c527a0264fc89a25ec41a..df9d1a9b4df5c0dc84f747f1f93ab963c84c1b9f 100644 (file)
@@ -106,6 +106,7 @@ Diskstream::Diskstream (Session &sess, const string &name, Flag flag)
         , _target_speed (_speed)
         , file_frame (0)
         , playback_sample (0)
+        , playback_distance (0)
         , _read_data_count (0)
         , _write_data_count (0)
         , in_set_state (false)
@@ -149,6 +150,7 @@ Diskstream::Diskstream (Session& sess, const XMLNode& /*node*/)
         , _target_speed (_speed)
         , file_frame (0)
         , playback_sample (0)
+        , playback_distance (0)
         , _read_data_count (0)
         , _write_data_count (0)
         , in_set_state (false)
index 50ad39c57613beb7d3f4ed0e9963b581e8470e74..f434af50f39eb93469ef2d43ab5c72a17dd28304 100644 (file)
@@ -496,6 +496,8 @@ MidiDiskstream::process (framepos_t transport_frame, pframes_t nframes, bool can
        bool      nominally_recording;
        bool      re = record_enabled ();
 
+       playback_distance = 0;
+
        check_record_status (transport_frame, can_record);
 
        nominally_recording = (can_record && re);
@@ -557,10 +559,31 @@ MidiDiskstream::process (framepos_t transport_frame, pframes_t nframes, bool can
        }
 
        if (rec_nframes) {
+
                /* data will be written to disk */
+
+               if (rec_nframes == nframes && rec_offset == 0) {
+                       playback_distance = nframes;
+               }
+
                adjust_capture_position = rec_nframes;
+
+       } else if (nominally_recording) {
+
+               /* XXXX do this for MIDI !!!
+                  can't do actual capture yet - waiting for latency effects to finish before we start
+                  */
+
+               playback_distance = nframes;
+
+       } else {
+
+               /* XXX: should be doing varispeed stuff here, similar to the code in AudioDiskstream::process */
+
+               playback_distance = nframes;
+
        }
-       
+
        ret = 0;
 
        if (commit (nframes)) {
@@ -576,9 +599,9 @@ MidiDiskstream::commit (framecnt_t nframes)
        bool need_butler = false;
 
        if (_actual_speed < 0.0) {
-               playback_sample -= nframes;
+               playback_sample -= playback_distance;
        } else {
-               playback_sample += nframes;
+               playback_sample += playback_distance;
        }
 
        if (adjust_capture_position != 0) {