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
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 16 additions & 12 deletions src/engine/controls/loopingcontrol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -946,31 +946,35 @@ void LoopingControl::slotReloopAndStop(double pressed) {

void LoopingControl::slotLoopStartPos(double positionSamples) {
// This slot is called before trackLoaded() for a new Track
const auto position = mixxx::audio::FramePos::fromEngineSamplePosMaybeInvalid(positionSamples);

LoopInfo loopInfo = m_loopInfo.getValue();
if (loopInfo.startPosition == position) {
//nothing to do
return;

{
const auto position =
mixxx::audio::FramePos::fromEngineSamplePosMaybeInvalid(
positionSamples);
if (loopInfo.startPosition == position) {
// Nothing to do
return;
}
loopInfo.startPosition = position;
}

loopInfo.seekMode = LoopSeekMode::MovedOut;

clearActiveBeatLoop();

if (!position.isValid()) {
if (!loopInfo.startPosition.isValid()) {
emit loopReset();
setLoopingEnabled(false);
}

loopInfo.seekMode = LoopSeekMode::MovedOut;
loopInfo.startPosition = position;
m_pCOLoopStartPosition->set(position.toEngineSamplePosMaybeInvalid());

if (loopInfo.endPosition.isValid() && loopInfo.endPosition <= loopInfo.startPosition) {
} else if (loopInfo.endPosition.isValid() && loopInfo.endPosition <= loopInfo.startPosition) {
emit loopReset();
loopInfo.endPosition = mixxx::audio::kInvalidFramePos;
m_pCOLoopEndPosition->set(kNoTrigger);
setLoopingEnabled(false);
}

m_pCOLoopStartPosition->set(loopInfo.startPosition.toEngineSamplePosMaybeInvalid());
m_loopInfo.setValue(loopInfo);
}

Expand Down