Skip to content

Commit

Permalink
simplify looping task duration check
Browse files Browse the repository at this point in the history
  • Loading branch information
anokta committed Feb 10, 2025
1 parent fb88a04 commit 98c245c
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions src/engine/performer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ std::optional<double> Performer::GetNextDuration() const noexcept {
return std::nullopt;
}

const double loop_end_position = GetLoopEndPosition();
std::optional<double> next_position = std::nullopt;

// Check inactive tasks.
Expand All @@ -76,17 +77,13 @@ std::optional<double> Performer::GetNextDuration() const noexcept {
// Performer position is inside an inactive task, we can return immediately.
return 0.0;
}
if (is_looping_ && next_it->first < position_) {
if (loop_length_ > 0.0) { // loop around.
next_position = next_it->first + loop_length_;
}
} else {
if (next_it->first < position_) { // loop around.
next_position = next_it->first + loop_length_;
} else if (!is_looping_ || next_it->first < loop_end_position) {
next_position = next_it->first;
}
}

const double loop_end_position = GetLoopEndPosition();

// Check active tasks.
if (!active_tasks_.empty()) {
if (const double next_active_task_position =
Expand Down

0 comments on commit 98c245c

Please sign in to comment.