summaryrefslogtreecommitdiffstats
path: root/src/engine/sync
diff options
context:
space:
mode:
authorOwen Williams <owilliams@mixxx.org>2020-05-01 18:06:50 -0400
committerOwen Williams <owilliams@mixxx.org>2020-05-10 22:36:46 -0400
commit26d30d592c763c4fa62877462394b663358d2c7e (patch)
treea70a4a336696bdbe2ac22a51b6f28b7cc6946e37 /src/engine/sync
parent88fca880612ce8b3413e58b62e83754f7353f451 (diff)
master sync: better algorithm to pick decks to sync to
Diffstat (limited to 'src/engine/sync')
-rw-r--r--src/engine/sync/basesyncablelistener.h2
-rw-r--r--src/engine/sync/enginesync.cpp24
-rw-r--r--src/engine/sync/enginesync.h7
-rw-r--r--src/engine/sync/syncable.h3
-rw-r--r--src/engine/sync/synccontrol.cpp9
-rw-r--r--src/engine/sync/synccontrol.h2
6 files changed, 13 insertions, 34 deletions
diff --git a/src/engine/sync/basesyncablelistener.h b/src/engine/sync/basesyncablelistener.h
index 1d6bda6a6d..006ed85ebb 100644
--- a/src/engine/sync/basesyncablelistener.h
+++ b/src/engine/sync/basesyncablelistener.h
@@ -22,8 +22,8 @@ class BaseSyncableListener : public SyncableListener {
void onCallbackStart(int sampleRate, int bufferSize);
void onCallbackEnd(int sampleRate, int bufferSize);
- Syncable* getSyncableForGroup(const QString& group);
// Only for testing. Do not use.
+ Syncable* getSyncableForGroup(const QString& group);
Syncable* getMasterSyncable() override {
return m_pMasterSyncable;
}
diff --git a/src/engine/sync/enginesync.cpp b/src/engine/sync/enginesync.cpp
index bcc1d82130..28f19f5718 100644
--- a/src/engine/sync/enginesync.cpp
+++ b/src/engine/sync/enginesync.cpp
@@ -429,18 +429,12 @@ void EngineSync::deactivateSync(Syncable* pSyncable) {
}
}
-Syncable* EngineSync::pickSyncTarget(Syncable* pDontPick) const {
- // First choice: Pick the sync master (unless the master is the pDontPick)
- if (m_pMasterSyncable && m_pMasterSyncable != pDontPick) {
- qDebug() << "MASTER????" << m_pMasterSyncable->getGroup()
- << m_pMasterSyncable->getChannel();
- return m_pMasterSyncable;
- }
-
- pSyncable* pFirstPlayingDeck = nullptr;
- pSyncable* pFirstNonplayingDeck = nullptr;
+Syncable* EngineSync::pickNonSyncSyncTarget(EngineChannel* pDontPick) const {
+ Syncable* pFirstPlayingDeck = nullptr;
+ Syncable* pFirstNonplayingDeck = nullptr;
foreach (Syncable* pSyncable, m_syncables) {
EngineChannel* pChannel = pSyncable->getChannel();
+ // Exclude non-decks
if (pChannel == nullptr || pChannel == pDontPick) {
continue;
}
@@ -452,7 +446,7 @@ Syncable* EngineSync::pickSyncTarget(Syncable* pDontPick) const {
if (pBuffer && pBuffer->getBpm() > 0) {
if (pBuffer->getSpeed() != 0.0) {
if (pSyncable->getSyncMode() != SYNC_NONE) {
- // Second choice: first playing sync deck
+ // First choice: first playing sync deck
qDebug() << "SYNC PLAYING";
return pSyncable;
}
@@ -466,7 +460,7 @@ Syncable* EngineSync::pickSyncTarget(Syncable* pDontPick) const {
}
}
if (pFirstPlayingDeck) {
- // Third choice: first playing non-sync deck
+ // Second choice: first playing non-sync deck
qDebug() << "PLAYING NON SYNC";
return pFirstPlayingDeck;
}
@@ -477,9 +471,9 @@ Syncable* EngineSync::pickSyncTarget(Syncable* pDontPick) const {
return pFirstNonplayingDeck;
}
-EngineBuffer* EngineSync::getEngineBufferForMaster() const {
- EngineChannel* channel = pickSyncTarget(m_pInternalClock);
-}
+// EngineBuffer* EngineSync::getEngineBufferForMaster() const {
+// EngineChannel* channel = pickSyncTarget(m_pInternalClock);
+// }
bool EngineSync::otherSyncedPlaying(const QString& group) {
bool othersInSync = false;
diff --git a/src/engine/sync/enginesync.h b/src/engine/sync/enginesync.h
index 7adefc30b6..f86fcb9bf3 100644
--- a/src/engine/sync/enginesync.h
+++ b/src/engine/sync/enginesync.h
@@ -51,16 +51,15 @@ class EngineSync : public BaseSyncableListener {
void notifyPlaying(Syncable* pSyncable, bool playing) override;
void notifyScratching(Syncable* pSyncable, bool scratching) override;
- // Used to pick a sync target whether in master sync mode or not.
- // It will first pick the sync master, if any,
+ // Used to pick a sync target for non-master-sync mode.
// then it will fall back to the first playing syncable deck,
// then it will fall back to the first playing deck,
// then it will fall back to the first non-playing deck.
- Syncable* pickSyncTarget(Syncable* pDontPick) const;
+ Syncable* pickNonSyncSyncTarget(EngineChannel* pDontPick) const;
// Returns the engine buffer for the Master, or if a
// non-deck is master, returns the next-best choice.
- EngineBuffer* getEngineBufferForMaster() const;
+ // EngineBuffer* getEngineBufferForMaster() const;
// Used to test whether changing the rate of a Syncable would change the rate
// of other Syncables that are playing
diff --git a/src/engine/sync/syncable.h b/src/engine/sync/syncable.h
index 0fbcd81027..68f60b6ce7 100644
--- a/src/engine/sync/syncable.h
+++ b/src/engine/sync/syncable.h
@@ -77,9 +77,6 @@ class Syncable {
virtual double getBeatLengthSeconds() const = 0;
// Gets the speed of the syncable if it was playing at 1.0 rate.
virtual double getBaseBpm() const = 0;
- // // Returns the effective key of the syncable.
- // virtual mixxx::track::io::key::ChromaticKey getKey() const = 0;
- // virtual double getVisualKeyDistance() const = 0;
// The following functions are used to tell syncables about the state of the
// current Sync Master.
diff --git a/src/engine/sync/synccontrol.cpp b/src/engine/sync/synccontrol.cpp
index 57f2f9e432..fbaa6780f1 100644
--- a/src/engine/sync/synccontrol.cpp
+++ b/src/engine/sync/synccontrol.cpp
@@ -231,15 +231,6 @@ double SyncControl::getBaseBpm() const {
return m_pLocalBpm->get() / m_masterBpmAdjustFactor;
}
-mixxx::track::io::key::ChromaticKey SyncControl::getKey() const {
- double dKey = ControlObject::get(ConfigKey(getGroup(), "key"));
- return KeyUtils::keyFromNumericValue(dKey);
-}
-
-double SyncControl::getVisualKeyDistance() const {
- return ControlObject::get(ConfigKey(getGroup(), "visual_key_distance"));
-}
-
void SyncControl::setMasterBeatDistance(double beatDistance) {
if (kLogger.traceEnabled()) {
kLogger.trace() << getGroup() << "SyncControl::setMasterBeatDistance"
diff --git a/src/engine/sync/synccontrol.h b/src/engine/sync/synccontrol.h
index cf10ee4dde..e4e78f9042 100644
--- a/src/engine/sync/synccontrol.h
+++ b/src/engine/sync/synccontrol.h
@@ -38,8 +38,6 @@ class SyncControl : public EngineControl, public Syncable {
double adjustSyncBeatDistance(double beatDistance) const;
double getBeatDistance() const override;
double getBeatLengthSeconds() const override;
- mixxx::track::io::key::ChromaticKey getKey() const override;
- double getVisualKeyDistance() const override;
void updateTargetBeatDistance();
double getBaseBpm() const override;
void setLocalBpm(double local_bpm);