X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Faudio_diskstream.cc;h=77c14de10338f07396a5caf7de59b5c0f8742ea6;hb=6bcdf4f0f106d0b83ed7f221f546c132585e19e7;hp=5c98271e5fc162e81f29001b4d98b8171f7b7da7;hpb=9ac6bb9befa047a6c349bed02d40da84600b67cc;p=ardour.git diff --git a/libs/ardour/audio_diskstream.cc b/libs/ardour/audio_diskstream.cc index 5c98271e5f..77c14de103 100644 --- a/libs/ardour/audio_diskstream.cc +++ b/libs/ardour/audio_diskstream.cc @@ -700,6 +700,31 @@ AudioDiskstream::process (BufferSet& bufs, framepos_t transport_frame, pframes_t return 0; } +frameoffset_t +AudioDiskstream::calculate_playback_distance (pframes_t nframes) +{ + frameoffset_t playback_distance = nframes; + + if (record_enabled()) { + playback_distance = nframes; + } else if (_actual_speed != 1.0f && _actual_speed != -1.0f) { + interpolation.set_speed (_target_speed); + boost::shared_ptr c = channels.reader(); + int channel = 0; + for (ChannelList::iterator chan = c->begin(); chan != c->end(); ++chan, ++channel) { + playback_distance = interpolation.interpolate (channel, nframes, NULL, NULL); + } + } else { + playback_distance = nframes; + } + + if (_actual_speed < 0.0) { + return -playback_distance; + } else { + return playback_distance; + } +} + /** Update various things including playback_sample, read pointer on each channel's playback_buf * and write pointer on each channel's capture_buf. Also wout whether the butler is needed. * @return true if the butler is required. @@ -900,7 +925,7 @@ AudioDiskstream::internal_playback_seek (framecnt_t distance) boost::shared_ptr c = channels.reader(); for (chan = c->begin(); chan != c->end(); ++chan) { - (*chan)->playback_buf->increment_read_ptr (distance); + (*chan)->playback_buf->increment_read_ptr (llabs(distance)); } if (first_recordable_frame < max_framepos) {