Skip to content

Commit

Permalink
Sync Lock: Fix missing case in prefer-internal-clock
Browse files Browse the repository at this point in the history
  • Loading branch information
ywwg committed May 14, 2021
1 parent db06e5a commit 67580bb
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/engine/sync/enginesync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
1 change: 1 addition & 0 deletions src/engine/sync/enginesync.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
21 changes: 21 additions & 0 deletions src/test/enginesynctest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<ControlProxy>(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.
Expand Down

0 comments on commit 67580bb

Please sign in to comment.