Skip to content
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

Merged
merged 3 commits into from
Sep 7, 2021

Conversation

Holzhaus
Copy link
Member

@Holzhaus Holzhaus commented Sep 6, 2021

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() &&
Copy link
Contributor

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) ...?

Copy link
Member Author

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;
Copy link
Contributor

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.

Copy link
Member Author

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.
Copy link
Member

@daschuer daschuer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, Thank you.

@daschuer daschuer merged commit 97cd3df into mixxxdj:main Sep 7, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants