diff --git a/src/engine/sync/enginesync.cpp b/src/engine/sync/enginesync.cpp index 8a749fe2722..7602283d22d 100644 --- a/src/engine/sync/enginesync.cpp +++ b/src/engine/sync/enginesync.cpp @@ -263,7 +263,7 @@ Syncable* EngineSync::pickMaster(Syncable* enabling_syncable) { return m_pInternalClock; } - if (stopped_deck_count > 1) { + if (stopped_deck_count >= 1) { return first_stopped_deck; } break; diff --git a/src/engine/sync/enginesync.h b/src/engine/sync/enginesync.h index ba6768ad4de..426c5256f88 100644 --- a/src/engine/sync/enginesync.h +++ b/src/engine/sync/enginesync.h @@ -150,6 +150,7 @@ class EngineSync : public SyncableListener { FRIEND_TEST(EngineSyncTest, SyncToNonSyncDeck); FRIEND_TEST(EngineSyncTest, SetFileBpmUpdatesLocalBpm); FRIEND_TEST(EngineSyncTest, BpmAdjustFactor); + FRIEND_TEST(EngineSyncTest, MomentarySyncAlgorithmTwo); friend class EngineSyncTest; UserSettingsPointer m_pConfig; diff --git a/src/test/enginesynctest.cpp b/src/test/enginesynctest.cpp index 30c28ee35b1..7d00c4a7e2e 100644 --- a/src/test/enginesynctest.cpp +++ b/src/test/enginesynctest.cpp @@ -907,6 +907,27 @@ TEST_F(EngineSyncTest, EnableOneDeckInitsMaster) { ConfigKey(m_sInternalClockGroup, "beat_distance"))); } +TEST_F(EngineSyncTest, MomentarySyncAlgorithmTwo) { + m_pConfig->set(ConfigKey("[BPM]", "sync_lock_algorithm"), + ConfigValue(EngineSync::PREFER_LOCK_BPM)); + + mixxx::BeatsPointer pBeats1 = BeatFactory::makeBeatGrid(m_pTrack1->getSampleRate(), 120, 0.0); + m_pTrack1->trySetBeats(pBeats1); + mixxx::BeatsPointer pBeats2 = BeatFactory::makeBeatGrid(m_pTrack2->getSampleRate(), 128, 0.0); + m_pTrack2->trySetBeats(pBeats2); + + ControlObject::getControl(ConfigKey(m_sGroup2, "play"))->set(1.0); + + auto pButtonSyncEnabled1 = + std::make_unique(m_sGroup1, "sync_enabled"); + pButtonSyncEnabled1->slotSet(1.0); + pButtonSyncEnabled1->slotSet(0.0); + + ProcessBuffer(); + + EXPECT_DOUBLE_EQ(128.0, ControlObject::get(ConfigKey(m_sGroup1, "bpm"))); +} + TEST_F(EngineSyncTest, EnableOneDeckInitializesMaster) { // Enabling sync on a deck causes it to be master, and sets bpm and clock. // Set the deck to play.