-
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
LoopingControl: Handle invalid start position properly (lp1942715) #4266
Conversation
An invalid start position resets the loop anyway. See this for details: https://bugs.launchpad.net/mixxx/+bug/1942715
@@ -965,7 +965,8 @@ void LoopingControl::slotLoopStartPos(double positionSamples) { | |||
loopInfo.startPosition = position; | |||
m_pCOLoopStartPosition->set(position.toEngineSamplePosMaybeInvalid()); | |||
|
|||
if (loopInfo.endPosition.isValid() && loopInfo.endPosition <= loopInfo.startPosition) { | |||
if (loopInfo.startPosition.isValid() && loopInfo.endPosition.isValid() && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We already checked for position.isValid()
above. I don't see a reason why we cannot combine these code paths like if (!loopInfo.startPosition.isValid() || !loopInfo.endPosition().isValid() || loopInfo.endPosition <= loopInfo.startPosition) ...
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
emit loopReset(); | ||
loopInfo.endPosition = mixxx::audio::kInvalidFramePos; | ||
m_pCOLoopEndPosition->set(kNoTrigger); | ||
setLoopingEnabled(false); | ||
} | ||
|
||
loopInfo.seekMode = LoopSeekMode::MovedOut; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let's move these lines up, closer to where loopInfo
is initialized.
Then use loopInfo.startPosition
instead of position
for consistency and to reveal the dependencies. For me this is easier to follow. Less variables to remember, more concise.
Compile time enforcement: Use a local scope so that the temporary position
becomes unavailable for the remainder of the function body.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
…Pos()` This sets loopInfo.startPosition first and then uses it instead of `position` for consistency and to reveal the dependencies. Also usees a local scope so that the temporary `position` becomes unavailable for the remainder of the function body.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, Thank you.
An invalid start position resets the loop anyway.
See this for details: https://bugs.launchpad.net/mixxx/+bug/1942715