diff options
author | Daniel Schürmann <daschuer@mixxx.org> | 2020-04-13 14:48:02 +0200 |
---|---|---|
committer | Daniel Schürmann <daschuer@mixxx.org> | 2020-04-21 22:38:43 +0200 |
commit | 2bceb45db3875873d0cf6021612901b4ad13c5f7 (patch) | |
tree | c4a3aa2db5aa8f906673c7419bbcd6659e1c434c /src/engine/sync | |
parent | 598143fc8fe9c09d4ab271b84dc82c8ee20b7be7 (diff) |
Get rid of legacy EngineSync::notifyTrackLoaded
Diffstat (limited to 'src/engine/sync')
-rw-r--r-- | src/engine/sync/basesyncablelistener.h | 4 | ||||
-rw-r--r-- | src/engine/sync/enginesync.cpp | 35 | ||||
-rw-r--r-- | src/engine/sync/enginesync.h | 1 | ||||
-rw-r--r-- | src/engine/sync/syncable.h | 7 | ||||
-rw-r--r-- | src/engine/sync/synccontrol.cpp | 21 |
5 files changed, 16 insertions, 52 deletions
diff --git a/src/engine/sync/basesyncablelistener.h b/src/engine/sync/basesyncablelistener.h index 5063d4f48e..ceeb693157 100644 --- a/src/engine/sync/basesyncablelistener.h +++ b/src/engine/sync/basesyncablelistener.h @@ -19,9 +19,9 @@ class BaseSyncableListener : public SyncableListener { // Only for testing. Do not use. Syncable* getSyncableForGroup(const QString& group); - Syncable* getMasterSyncable() { + Syncable* getMasterSyncable() override { return m_pMasterSyncable; - } + }; protected: // This utility method returns true if it finds a deck not in SYNC_NONE mode. diff --git a/src/engine/sync/enginesync.cpp b/src/engine/sync/enginesync.cpp index 4f529687db..fad87d9abb 100644 --- a/src/engine/sync/enginesync.cpp +++ b/src/engine/sync/enginesync.cpp @@ -130,7 +130,10 @@ void EngineSync::requestSyncMode(Syncable* pSyncable, SyncMode mode) { activateFollower(pSyncable); // Hand off to the internal clock and keep the current BPM and beat // distance. - activateMaster(m_pInternalClock, false); + Syncable* newMaster = pickMaster(pSyncable); + if (newMaster) { + activateMaster(newMaster, false); + } } else if (m_pMasterSyncable == nullptr) { // If no master active, activate the internal clock. activateMaster(m_pInternalClock, false); @@ -304,36 +307,6 @@ void EngineSync::notifyPlaying(Syncable* pSyncable, bool playing) { pSyncable->requestSync(); } -void EngineSync::notifyTrackLoaded(Syncable* pSyncable, double suggested_bpm) { - if (kLogger.traceEnabled()) { - kLogger.trace() << "EngineSync::notifyTrackLoaded"; - } - // If there are no other sync decks, initialize master based on this. - // If there is, make sure to set our rate based on that. - - // TODO(owilliams): Check this logic with an explicit master - if (pSyncable->getSyncMode() != SYNC_FOLLOWER) { - return; - } - - bool sync_deck_exists = false; - foreach (const Syncable* pOtherSyncable, m_syncables) { - if (pOtherSyncable == pSyncable) { - continue; - } - if (pOtherSyncable->isSynchronized() && pOtherSyncable->getBpm() != 0) { - sync_deck_exists = true; - break; - } - } - - if (!sync_deck_exists) { - setMasterBpm(pSyncable, suggested_bpm); - } else { - pSyncable->setMasterBpm(masterBpm()); - } -} - void EngineSync::notifyScratching(Syncable* pSyncable, bool scratching) { // No special behavior for now. Q_UNUSED(pSyncable); diff --git a/src/engine/sync/enginesync.h b/src/engine/sync/enginesync.h index 126e51352a..1dc1fef6dd 100644 --- a/src/engine/sync/enginesync.h +++ b/src/engine/sync/enginesync.h @@ -46,7 +46,6 @@ class EngineSync : public BaseSyncableListener { void notifyBeatDistanceChanged(Syncable* pSyncable, double beatDistance) override; void notifyPlaying(Syncable* pSyncable, bool playing) override; void notifyScratching(Syncable* pSyncable, bool scratching) override; - void notifyTrackLoaded(Syncable* pSyncable, double suggested_bpm) override; // Used to pick a sync target for non-master-sync mode. EngineChannel* pickNonSyncSyncTarget(EngineChannel* pDontPick) const; diff --git a/src/engine/sync/syncable.h b/src/engine/sync/syncable.h index 5449c78100..bd708dead6 100644 --- a/src/engine/sync/syncable.h +++ b/src/engine/sync/syncable.h @@ -128,11 +128,8 @@ class SyncableListener { Syncable* pSyncable, double beatDistance) = 0; virtual void notifyPlaying(Syncable* pSyncable, bool playing) = 0; - // A syncable can notify that a track has been loaded, and passes in the bpm - // that it would be set at if the rate slider were left alone. This allows - // the master sync engine to either use that rate, if it pleases, or sets - // the syncable to the existing master bpm. - virtual void notifyTrackLoaded(Syncable* pSyncable, double suggested_bpm) = 0; + + virtual Syncable* getMasterSyncable() = 0; }; #endif /* SYNCABLE_H */ diff --git a/src/engine/sync/synccontrol.cpp b/src/engine/sync/synccontrol.cpp index 9421d96028..fa63627567 100644 --- a/src/engine/sync/synccontrol.cpp +++ b/src/engine/sync/synccontrol.cpp @@ -347,21 +347,16 @@ void SyncControl::trackBeatsUpdated(BeatsPointer pBeats) { } m_pBeats = pBeats; - if (getSyncMode() == SYNC_MASTER_SOFT) { + m_masterBpmAdjustFactor = kBpmUnity; + + SyncMode syncMode = getSyncMode(); + if (syncMode == SYNC_MASTER_SOFT) { // If we change or remove beats while soft master, hand off. m_pChannel->getEngineBuffer()->requestSyncMode(SYNC_FOLLOWER); + } else if (syncMode == SYNC_FOLLOWER) { + // Refresh follower state to update soft master + m_pChannel->getEngineBuffer()->requestSyncMode(SYNC_FOLLOWER); } - if (pBeats) { - m_masterBpmAdjustFactor = kBpmUnity; - if (isSynchronized()) { - // We used to set the m_pBpm here, but that causes a signal loop whereby - // that was interpreted as a rate slider tweak, and the master bpm - // was changed. Instead, now we pass the suggested bpm to enginesync - // explicitly, and it can decide what to do with it. - m_pEngineSync->notifyTrackLoaded(this, m_pLocalBpm->get() * m_pRateRatio->get()); - } - } - setLocalBpm(m_pLocalBpm->get()); } @@ -395,7 +390,7 @@ void SyncControl::slotSyncModeChangeRequest(double state) { if (kLogger.traceEnabled()) { kLogger.trace() << getGroup() << "SyncControl::slotSyncModeChangeRequest"; } - SyncMode mode(syncModeFromDouble(state)); + SyncMode mode = syncModeFromDouble(state); if (m_pPassthroughEnabled->get() && mode != SYNC_NONE) { qDebug() << "Disallowing enabling of sync mode when passthrough active"; } else { |