diff options
author | Robin Gareus <robin@gareus.org> | 2016-07-25 19:46:19 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2016-07-25 19:46:19 +0200 |
commit | 90a67d04d5691d59e2a070de79b1f005b99b6f70 (patch) | |
tree | 68857ba15e7b1c9ea22fac6a0382f0a0d9639b96 | |
parent | 994df3aaa370125d3fa442baa38392a32c640e69 (diff) |
another attempt to fix playhead position with varispeed.
-rw-r--r-- | libs/ardour/session.cc | 50 |
1 files changed, 23 insertions, 27 deletions
diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 63cd20a0c0..272bd765e6 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -2030,59 +2030,55 @@ framepos_t Session::audible_frame () const { framepos_t ret; - framepos_t tf; - framecnt_t offset; - offset = worst_playback_latency (); + frameoffset_t offset = worst_playback_latency (); // - _engine.samples_since_cycle_start (); + offset *= transport_speed (); if (synced_to_engine()) { /* Note: this is basically just sync-to-JACK */ - tf = _engine.transport_frame(); + ret = _engine.transport_frame(); } else { - tf = _transport_frame; + ret = _transport_frame; } - ret = tf; - - if (!non_realtime_work_pending()) { - - /* MOVING */ + if (transport_rolling()) { + ret -= offset; /* Check to see if we have passed the first guaranteed - audible frame past our last start position. if not, - return that last start point because in terms - of audible frames, we have not moved yet. - - `Start position' in this context means the time we last - either started, located, or changed transport direction. - */ + * audible frame past our last start position. if not, + * return that last start point because in terms + * of audible frames, we have not moved yet. + * + * `Start position' in this context means the time we last + * either started, located, or changed transport direction. + */ if (_transport_speed > 0.0f) { if (!play_loop || !have_looped) { - if (tf < _last_roll_or_reversal_location + offset) { + if (ret < _last_roll_or_reversal_location) { return _last_roll_or_reversal_location; } + } else { + // latent loops + Location *location = _locations->auto_loop_location(); + frameoffset_t lo = location->start() - ret; + if (lo > 0) { + ret = location->end () - lo; + } } - - /* forwards */ - ret -= offset; - } else if (_transport_speed < 0.0f) { /* XXX wot? no backward looping? */ - if (tf > _last_roll_or_reversal_location - offset) { + if (ret > _last_roll_or_reversal_location) { return _last_roll_or_reversal_location; - } else { - /* backwards */ - ret += offset; } } } - return ret; + return std::max (0l, ret); } void |