Do not queue TransportStateChanged events (and thus signals) when locating from the end of a loop.

There is no event processing after the locate, and so the event that is (was)
queued at the loop start will not be processed, and each time we reach the
loop end, we will try (and fail) to queue an identical event (fail because
duplicate events are not allowed). We don't need this event (or signal) at
all, because locates (and then ::start_transport() while looping do not
represent a state change that any UI needs to know about.
This commit is contained in:
Paul Davis 2021-07-26 17:21:57 -06:00
parent 0271f36e1d
commit cd7c222942
4 changed files with 19 additions and 14 deletions

View File

@ -1348,7 +1348,7 @@ protected:
void locate (samplepos_t, bool for_loop_end=false, bool force=false, bool with_mmc=true);
void stop_transport (bool abort = false, bool clear_state = false);
void start_transport ();
void start_transport (bool after_loop);
void butler_completed_transport_work ();
void post_locate ();
void schedule_butler_for_transport_work ();

View File

@ -37,7 +37,7 @@ class LIBARDOUR_API TransportAPI
virtual void locate (samplepos_t, bool with_loop=false, bool force=false, bool with_mmc=true) = 0;
virtual bool should_stop_before_locate () const = 0;
virtual void stop_transport (bool abort = false, bool clear_state = false) = 0;
virtual void start_transport () = 0;
virtual void start_transport (bool after_loop) = 0;
virtual void butler_completed_transport_work () = 0;
virtual void schedule_butler_for_transport_work () = 0;
virtual bool should_roll_after_locate () const = 0;

View File

@ -446,7 +446,7 @@ Session::stop_transport (bool abort, bool clear_state)
/** Called from the process thread */
void
Session::start_transport ()
Session::start_transport (bool after_loop)
{
ENSURE_PROCESS_THREAD;
DEBUG_TRACE (DEBUG::Transport, "start_transport\n");
@ -570,15 +570,19 @@ Session::start_transport ()
DEBUG_TRACE (DEBUG::Transport, string_compose ("send TSC4 with speed = %1\n", transport_speed()));
/* emit TransportStateChange signal only when transport is actually rolling */
SessionEvent* ev = new SessionEvent (SessionEvent::TransportStateChange, SessionEvent::Add, _transport_sample, _transport_sample, 1.0);
queue_event (ev);
samplepos_t roll_pos = _transport_sample + std::max (_count_in_samples, _remaining_latency_preroll) * (_transport_fsm->will_roll_fowards () ? 1 : -1);
if (roll_pos > 0 && roll_pos != _transport_sample) {
/* and when transport_rolling () == true */
SessionEvent* ev = new SessionEvent (SessionEvent::TransportStateChange, SessionEvent::Add, roll_pos, roll_pos, 1.0);
if (!after_loop) {
/* emit TransportStateChange signal only when transport is actually rolling */
SessionEvent* ev = new SessionEvent (SessionEvent::TransportStateChange, SessionEvent::Add, _transport_sample, _transport_sample, 1.0);
cerr << "queueing TSC1 @ " << _transport_sample << endl;
queue_event (ev);
samplepos_t roll_pos = _transport_sample + std::max (_count_in_samples, _remaining_latency_preroll) * (_transport_fsm->will_roll_fowards () ? 1 : -1);
if (roll_pos > 0 && roll_pos != _transport_sample) {
/* and when transport_rolling () == true */
SessionEvent* ev = new SessionEvent (SessionEvent::TransportStateChange, SessionEvent::Add, roll_pos, roll_pos, 1.0);
cerr << "queueing TSC2 @ " << roll_pos << endl;
queue_event (ev);
}
}
}

View File

@ -484,7 +484,7 @@ TransportFSM::start_playback ()
api->set_transport_speed (most_recently_requested_speed);
}
api->start_transport();
api->start_transport (false);
}
void
@ -688,7 +688,8 @@ TransportFSM::should_roll_after_locate () const
void
TransportFSM::roll_after_locate () const
{
DEBUG_TRACE (DEBUG::TFSMEvents, string_compose ("rolling after locate, was for_loop ? %1\n", _last_locate.for_loop_end));
bool for_loop = _last_locate.for_loop_end;
DEBUG_TRACE (DEBUG::TFSMEvents, string_compose ("rolling after locate, was for_loop ? %1\n", for_loop));
current_roll_after_locate_status = boost::none;
if (most_recently_requested_speed == std::numeric_limits<double>::max()) {
@ -699,7 +700,7 @@ TransportFSM::roll_after_locate () const
}
api->set_transport_speed (most_recently_requested_speed);
api->start_transport ();
api->start_transport (for_loop);
}
void