Add short delay at the end of a loop

This commit is contained in:
Dan Paulat 2023-05-27 01:25:51 -05:00
parent ba1de683fa
commit 5970eaf678

View file

@ -261,25 +261,38 @@ void TimelineManager::Impl::Play()
// Determine loop start time and current position in the loop // Determine loop start time and current position in the loop
std::chrono::system_clock::time_point startTime = endTime - loopTime_; std::chrono::system_clock::time_point startTime = endTime - loopTime_;
std::chrono::system_clock::time_point currentTime = selectedTime_; std::chrono::system_clock::time_point currentTime = selectedTime_;
std::chrono::system_clock::time_point newTime;
// Unlock prior to selecting time
lock.unlock();
if (currentTime < startTime || currentTime >= endTime) if (currentTime < startTime || currentTime >= endTime)
{ {
// If the currently selected time is out of the loop, select the // If the currently selected time is out of the loop, select the
// start time // start time
SelectTime(startTime); newTime = startTime;
} }
else else
{ {
// If the currently selected time is in the loop, increment // If the currently selected time is in the loop, increment
SelectTime(currentTime + 1min); newTime = currentTime + 1min;
} }
// Determine repeat interval (loop speed of 1.0 is 1 minute per second) // Unlock prior to selecting time
std::chrono::milliseconds interval = lock.unlock();
std::chrono::milliseconds(std::lroundl(1000.0 / loopSpeed_));
// Select the time
SelectTime(newTime);
std::chrono::milliseconds interval;
if (newTime != endTime)
{
// Determine repeat interval (speed of 1.0 is 1 minute per second)
interval =
std::chrono::milliseconds(std::lroundl(1000.0 / loopSpeed_));
}
else
{
// Pause for 2.5 seconds at the end of the loop
interval = std::chrono::milliseconds(2500);
}
std::unique_lock animationTimerLock {animationTimerMutex_}; std::unique_lock animationTimerLock {animationTimerMutex_};