From 8b1df3e083802888d4144ca3e86b968e9b69565b Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 8 May 2021 17:58:40 -0600 Subject: [PATCH] fix bad transition problem in transportFSM when slowing to a stop that is then reversed --- libs/ardour/ardour/transport_fsm.h | 4 ++-- libs/ardour/transport_fsm.cc | 23 ++++++++++++++++------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/libs/ardour/ardour/transport_fsm.h b/libs/ardour/ardour/transport_fsm.h index d9779f3850..1b3f4d9a8b 100644 --- a/libs/ardour/ardour/transport_fsm.h +++ b/libs/ardour/ardour/transport_fsm.h @@ -168,7 +168,7 @@ struct TransportFSM void start_locate_while_stopped (Event const &) const; void interrupt_locate (Event const &) const; void start_declick_for_locate (Event const &); - void set_speed (Event const &); + bool set_speed (Event const &); /* guards */ @@ -216,7 +216,7 @@ struct TransportFSM void set_roll_after (bool) const; bool compute_should_roll (LocateTransportDisposition) const; int compute_transport_speed () const; - void maybe_reset_speed (); + bool maybe_reset_speed (); }; } /* end namespace ARDOUR */ diff --git a/libs/ardour/transport_fsm.cc b/libs/ardour/transport_fsm.cc index d1fbd72f4d..c381fbb310 100644 --- a/libs/ardour/transport_fsm.cc +++ b/libs/ardour/transport_fsm.cc @@ -427,9 +427,10 @@ TransportFSM::process_event (Event& ev, bool already_deferred, bool& deferred) start_locate_after_declick (); break; case DeclickToStop: - maybe_reset_speed (); - transition (Stopped); - /* transport already stopped */ + if (!maybe_reset_speed ()) { + transition (Stopped); + /* transport already stopped */ + } break; default: bad_transition (ev); return false; @@ -497,13 +498,15 @@ TransportFSM::stop_playback (Event const & s) api->stop_transport (s.abort_capture, s.clear_state); } -void +bool TransportFSM::maybe_reset_speed () { + bool state_changed = false; + if (Config->get_reset_default_speed_on_stop()) { if (most_recently_requested_speed != 1.0) { - set_speed (Event (1.0, false)); + state_changed = set_speed (Event (1.0, false)); } } else { @@ -516,9 +519,11 @@ TransportFSM::maybe_reset_speed () */ if (most_recently_requested_speed != _default_speed) { - set_speed (Event (_default_speed, false)); + state_changed = set_speed (Event (_default_speed, false)); } } + + return state_changed; } void @@ -753,7 +758,7 @@ TransportFSM::compute_transport_speed () const return 1; } -void +bool TransportFSM::set_speed (Event const & ev) { assert (ev.speed != 0.0); @@ -818,7 +823,11 @@ TransportFSM::set_speed (Event const & ev) transition (WaitingForLocate); start_locate_while_stopped (lev); } + + return true; } + + return false; } bool