diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index ad2e69d083..8088858917 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -681,7 +681,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop framepos_t transport_frame () const {return _transport_frame; } framepos_t record_location () const {return _last_record_location; } - framepos_t audible_frame () const; + framepos_t audible_frame (bool* latent_locate = NULL) const; framepos_t requested_return_frame() const { return _requested_return_frame; } void set_requested_return_frame(framepos_t return_to); diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 2c3e1d2ef2..f55e95486e 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -2067,12 +2067,15 @@ Session::maybe_enable_record (bool rt_context) } framepos_t -Session::audible_frame () const +Session::audible_frame (bool* latent_locate) const { framepos_t ret; frameoffset_t offset = worst_playback_latency (); // - _engine.samples_since_cycle_start (); offset *= transport_speed (); + if (latent_locate) { + *latent_locate = false; + } if (synced_to_engine()) { /* Note: this is basically just sync-to-JACK */ @@ -2097,14 +2100,24 @@ Session::audible_frame () const if (!play_loop || !have_looped) { if (ret < _last_roll_or_reversal_location) { + if (latent_locate) { + *latent_locate = true; + } return _last_roll_or_reversal_location; } } else { - // latent loops + /* the play-position wrapped at the loop-point + * ardour is already playing the beginning of the loop, + * but due to playback latency, the "audible frame" + * is still at the end of the loop. + */ Location *location = _locations->auto_loop_location(); frameoffset_t lo = location->start() - ret; if (lo > 0) { ret = location->end () - lo; + if (latent_locate) { + *latent_locate = true; + } } } diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 1b93e41c3c..72da3e6788 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -233,7 +233,7 @@ Session::post_engine_init () msc->set_input_port (boost::dynamic_pointer_cast(scene_input_port())); msc->set_output_port (boost::dynamic_pointer_cast(scene_output_port())); - boost::function timer_func (boost::bind (&Session::audible_frame, this)); + boost::function timer_func (boost::bind (&Session::audible_frame, this, (bool*)(0))); boost::dynamic_pointer_cast(scene_input_port())->set_timer (timer_func); setup_midi_machine_control ();