Skip to content

Commit

Permalink
Merge pull request #4266 from Holzhaus/looping-startpos-fix
Browse files Browse the repository at this point in the history
LoopingControl: Handle invalid start position properly (lp1942715)
  • Loading branch information
daschuer authored Sep 7, 2021
2 parents dc8ef5b + 6fe9011 commit 97cd3df
Showing 1 changed file with 16 additions and 12 deletions.
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

0 comments on commit 97cd3df

Please sign in to comment.