From a4b1a1bb14515650d7120b7b2b3ac1874bbf3d5f Mon Sep 17 00:00:00 2001 From: Carl Hetherington Date: Mon, 2 May 2011 22:21:59 +0000 Subject: [PATCH] Factor out stop limit computation into its own method. Ignore stop-at-session-end if there is a punch range and punch-in is enabled (#4022). git-svn-id: svn://localhost/ardour2/branches/3.0@9457 d708f5d6-7413-0410-9779-e7cbd77b26cf --- libs/ardour/ardour/session.h | 3 ++- libs/ardour/session_process.cc | 47 ++++++++++------------------------ 2 files changed, 16 insertions(+), 34 deletions(-) diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 82fe06a9f3..1d37f8583a 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -253,7 +253,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi return (RecordState) g_atomic_int_get (&_record_status); } - bool actively_recording () { + bool actively_recording () const { return record_status() == Recording; } @@ -1498,6 +1498,7 @@ class Session : public PBD::StatefulDestructible, public PBD::ScopedConnectionLi void end_time_changed (framepos_t); void set_track_monitor_input_status (bool); + framepos_t compute_stop_limit () const; boost::shared_ptr _speakers; }; diff --git a/libs/ardour/session_process.cc b/libs/ardour/session_process.cc index 3736c535fb..6911a5ec18 100644 --- a/libs/ardour/session_process.cc +++ b/libs/ardour/session_process.cc @@ -254,7 +254,6 @@ Session::process_with_events (pframes_t nframes) pframes_t this_nframes; framepos_t end_frame; bool session_needs_butler = false; - framepos_t stop_limit; framecnt_t frames_moved; /* make sure the auditioner is silent */ @@ -362,16 +361,7 @@ Session::process_with_events (pframes_t nframes) send_midi_time_code_for_cycle (_transport_frame, end_frame, nframes); } - if (actively_recording()) { - stop_limit = max_framepos; - } else { - - if (Config->get_stop_at_session_end()) { - stop_limit = current_end_frame(); - } else { - stop_limit = max_framepos; - } - } + framepos_t stop_limit = compute_stop_limit (); if (maybe_stop (stop_limit)) { no_roll (nframes); @@ -769,18 +759,7 @@ Session::follow_slave_silently (pframes_t nframes, float slave_speed) increment_transport_position (frames_moved); } - framepos_t stop_limit; - - if (actively_recording()) { - stop_limit = max_framepos; - } else { - if (Config->get_stop_at_session_end()) { - stop_limit = current_end_frame(); - } else { - stop_limit = max_framepos; - } - } - + framepos_t const stop_limit = compute_stop_limit (); maybe_stop (stop_limit); } } @@ -789,7 +768,6 @@ void Session::process_without_events (pframes_t nframes) { bool session_needs_butler = false; - framepos_t stop_limit; framecnt_t frames_moved; if (!process_can_proceed()) { @@ -820,15 +798,7 @@ Session::process_without_events (pframes_t nframes) send_midi_time_code_for_cycle (_transport_frame, _transport_frame + frames_moved, nframes); } - if (actively_recording()) { - stop_limit = max_framepos; - } else { - if (Config->get_stop_at_session_end()) { - stop_limit = current_end_frame(); - } else { - stop_limit = max_framepos; - } - } + framepos_t const stop_limit = compute_stop_limit (); if (maybe_stop (stop_limit)) { fail_roll (nframes); @@ -1174,3 +1144,14 @@ Session::process_event (SessionEvent* ev) } } +framepos_t +Session::compute_stop_limit () const +{ + bool const punching = (config.get_punch_in () && _locations->auto_punch_location()); + + if (!actively_recording() && !punching && Config->get_stop_at_session_end()) { + return current_end_frame (); + } + + return max_framepos; +}