Skip to content

Commit

Permalink
BpmControl: Add check to verify that loop positions are valid
Browse files Browse the repository at this point in the history
As suggested here: mixxxdj#4191 (comment)
  • Loading branch information
Holzhaus authored and ronso0 committed Sep 24, 2021
1 parent 8810241 commit 515eb54
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/engine/controls/bpmcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -451,10 +451,14 @@ double BpmControl::calcSyncedRate(double userTweak) {
const auto loopEndPosition =
mixxx::audio::FramePos::fromEngineSamplePosMaybeInvalid(
m_pLoopEndPosition->get());
const auto loopSize = (loopEndPosition - loopStartPosition) / beatLengthFrames;
if (loopSize < 1.0 && loopSize > 0) {
m_resetSyncAdjustment = true;
return rate + userTweak;
// This should always be true when a loop is enabled, but we check it
// anyway to prevent race conditions.
if (loopStartPosition.isValid() && loopEndPosition.isValid()) {
const auto loopSize = (loopEndPosition - loopStartPosition) / beatLengthFrames;
if (loopSize < 1.0 && loopSize > 0) {
m_resetSyncAdjustment = true;
return rate + userTweak;
}
}
}

Expand Down

0 comments on commit 515eb54

Please sign in to comment.