Skip to content

Commit

Permalink
Merge pull request #4682 from Holzhaus/enginebuffer-setlocalbpm-debug…
Browse files Browse the repository at this point in the history
…-assert-fix

EngineBuffer: Fix assert when new track is loaded during playback with sync
  • Loading branch information
ywwg authored Mar 7, 2022
2 parents ee3c510 + 9614a8f commit 74ec345
Showing 1 changed file with 15 additions and 11 deletions.
26 changes: 15 additions & 11 deletions src/engine/enginebuffer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1304,18 +1304,22 @@ void EngineBuffer::postProcess(const int iBufferSize) {
}
const mixxx::Bpm localBpm = m_pBpmControl->updateLocalBpm();
double beatDistance = m_pBpmControl->updateBeatDistance();
// FIXME: Double check if calling setLocalBpm with an invalid value is correct and intended.
mixxx::Bpm newLocalBpm;
const SyncMode mode = m_pSyncControl->getSyncMode();
if (localBpm.isValid()) {
newLocalBpm = localBpm;
}
m_pSyncControl->setLocalBpm(newLocalBpm);
SyncMode mode = m_pSyncControl->getSyncMode();
m_pSyncControl->reportPlayerSpeed(m_speed_old, m_scratching_old);
if (isLeader(mode)) {
m_pEngineSync->notifyBeatDistanceChanged(m_pSyncControl, beatDistance);
} else if (isFollower(mode)) {
m_pSyncControl->updateTargetBeatDistance();
m_pSyncControl->setLocalBpm(localBpm);
m_pSyncControl->reportPlayerSpeed(m_speed_old, m_scratching_old);
if (isLeader(mode)) {
m_pEngineSync->notifyBeatDistanceChanged(m_pSyncControl, beatDistance);
} else if (isFollower(mode)) {
m_pSyncControl->updateTargetBeatDistance();
}
} else if (mode == SyncMode::LeaderSoft) {
// If this channel has been automatically chosen to be the leader but
// no BPM is available, another channel may take over leadership and
// this channel becomes a follower. This may happen if the track is
// analyzed upon load and avoids sudden tempo jumps on the other deck
// while the analysis is still running.
requestSyncMode(SyncMode::Follower);
}

// Update all the indicators that EngineBuffer publishes to allow
Expand Down

0 comments on commit 74ec345

Please sign in to comment.