Skip to content

Commit

Permalink
Sync Lock: don't use c++17 inline conditional assignment (1)
Browse files Browse the repository at this point in the history
Co-authored-by: Daniel Schürmann <daschuer@mixxx.org>
  • Loading branch information
ywwg and daschuer committed Jun 1, 2021
1 parent 15cd3d4 commit 85bbc63
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 12 deletions.
22 changes: 13 additions & 9 deletions src/engine/sync/enginesync.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,9 @@ void EngineSync::requestSyncMode(Syncable* pSyncable, SyncMode mode) {
}
}

if (auto onlyPlayer = getOnlyPlayingSyncable(); onlyPlayer != nullptr) {
onlyPlayer->notifyOnlyPlayingSyncable();
Syncable* pOnlyPlayer = getUniqueSyncDeck();
if (pOnlyPlayer) {
pOnlyPlayer->notifyOnlyPlayingSyncable();
}
}

Expand Down Expand Up @@ -351,11 +352,14 @@ void EngineSync::notifyPlayingAudible(Syncable* pSyncable, bool playingAudible)
if (newMaster != nullptr && newMaster != m_pMasterSyncable) {
activateMaster(newMaster, SYNC_MASTER_SOFT);
setMasterParams(newMaster);
} else if (auto onlyPlayer = getOnlyPlayingSyncable(); onlyPlayer != nullptr) {
// Even if we didn't change master, if there is only one player (us), then we should
// reinit the beat distance.
onlyPlayer->notifyOnlyPlayingSyncable();
setMasterBeatDistance(onlyPlayer, onlyPlayer->getBeatDistance());
} else {
Syncable* pOnlyPlayer = getUniqueSyncDeck();
if (pOnlyPlayer) {
// Even if we didn't change master, if there is only one player (us), then we should
// reinit the beat distance.
pOnlyPlayer->notifyOnlyPlayingSyncable();
setMasterBeatDistance(pOnlyPlayer, pOnlyPlayer->getBeatDistance());
}
}

pSyncable->requestSync();
Expand Down Expand Up @@ -613,7 +617,7 @@ void EngineSync::setMasterParams(Syncable* pSource) {
if (!pSource->isPlaying()) {
// If the params source is not playing, but other syncables are, then we are a stopped
// explicit Master and we should not initialize the beat distance. Take it from the
// internal clock instead.
// internal clock instead, because that will be up to date with the playing deck(s).
bool playingSyncables = false;
for (Syncable* pSyncable : qAsConst(m_syncables)) {
if (pSyncable == pSource) {
Expand Down Expand Up @@ -651,7 +655,7 @@ void EngineSync::setMasterParams(Syncable* pSource) {
}
}

Syncable* EngineSync::getOnlyPlayingSyncable() const {
Syncable* EngineSync::getUniqueSyncDeck() const {
Syncable* onlyPlaying = nullptr;
for (Syncable* pSyncable : m_syncables) {
if (!pSyncable->isSynchronized()) {
Expand Down
6 changes: 3 additions & 3 deletions src/engine/sync/enginesync.h
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,9 @@ class EngineSync : public SyncableListener {

void setMasterParams(Syncable* pSource);

/// Iff there is a single playing syncable, return it. This is used to initialize master
/// params.
Syncable* getOnlyPlayingSyncable() const;
/// Iff there is a single playing syncable in sync mode, return it.
/// This is used to initialize master params.
Syncable* getUniqueSyncDeck() const;

/// Only for testing. Do not use.
Syncable* getSyncableForGroup(const QString& group);
Expand Down

0 comments on commit 85bbc63

Please sign in to comment.