summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/engine/sync/enginesync.h4
-rw-r--r--src/library/autodj/autodjprocessor.cpp88
-rw-r--r--src/mixer/basetrackplayer.cpp4
-rw-r--r--src/mixer/playerinfo.cpp10
-rw-r--r--src/mixer/playerinfo.h1
-rw-r--r--src/mixxx.cpp1
-rw-r--r--src/test/autodjprocessor_test.cpp22
-rw-r--r--src/test/signalpathtest.h21
8 files changed, 79 insertions, 72 deletions
diff --git a/src/engine/sync/enginesync.h b/src/engine/sync/enginesync.h
index 8374d81155..29fc05ff2b 100644
--- a/src/engine/sync/enginesync.h
+++ b/src/engine/sync/enginesync.h
@@ -52,11 +52,13 @@ class EngineSync : public BaseSyncableListener {
void notifyScratching(Syncable* pSyncable, bool scratching) override;
// Used to pick a sync target for cases where master sync mode is not sufficient.
- // Guaranteed to pick a Syncable that is a real deck and has an EngineBuffer.
+ // Guaranteed to pick a Syncable that is a real deck and has an EngineBuffer,
+ // but can return nullptr if there are no choices.
// First choice is master sync, if it's a real deck,
// 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.
+ // If there is literally nothing loaded, returns nullptr.
Syncable* pickNonSyncSyncTarget(EngineChannel* pDontPick) const;
// Used to test whether changing the rate of a Syncable would change the rate
diff --git a/src/library/autodj/autodjprocessor.cpp b/src/library/autodj/autodjprocessor.cpp
index 2f11e7e569..252171bed4 100644
--- a/src/library/autodj/autodjprocessor.cpp
+++ b/src/library/autodj/autodjprocessor.cpp
@@ -1223,7 +1223,7 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck,
double introLength = introEnd - introStart;
switch (m_transitionMode) {
- case TransitionMode::FullIntroOutro:
+ case TransitionMode::FullIntroOutro: {
// Use the outro or intro length for the transition time, whichever is
// shorter. Let the full outro and intro play; do not cut off any part
// of either.
@@ -1245,41 +1245,32 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck,
// If only the outro or intro length is marked but not both, use the one
// that is marked for the transition time. If neither is marked, fall
// back to the transition time from the spinbox.
- if (outroLength > 0 && introLength > 0) {
- if (outroLength > introLength) {
- pFromDeck->fadeBeginPos = outroEnd - introLength;
- pFromDeck->fadeEndPos = outroEnd;
- pToDeck->startPos = introStart;
- } else {
- pFromDeck->fadeBeginPos = outroStart;
- pFromDeck->fadeEndPos = outroEnd;
- pToDeck->startPos = introStart;
+ double transitionLength = introLength;
+ if (outroLength > 0) {
+ if (transitionLength <= 0 || transitionLength > outroLength) {
+ // Use outro length when the intro is not defined or longer
+ // than the outro.
+ transitionLength = outroLength;
}
- } else if (outroLength > 0 && introLength <= 0) {
- if (outroLength + introStart < pToDeck->fadeBeginPos) {
- pFromDeck->fadeBeginPos = outroStart;
- } else {
- // This happens if the toDeck track has no intro set and the
- // outro of the fromDeck track is longer than the whole toDeck
- // track
- outroLength = pToDeck->fadeBeginPos - introStart;
- VERIFY_OR_DEBUG_ASSERT(outroLength > 0) {
+ }
+ if (transitionLength > 0) {
+ const double transitionEnd = introStart + transitionLength;
+ if (transitionEnd > pToDeck->fadeBeginPos) {
+ // End intro before next outro starts
+ transitionLength = pToDeck->fadeBeginPos - introStart;
+ VERIFY_OR_DEBUG_ASSERT(transitionLength > 0) {
// We seek to intro start above in this case so this never happens
- outroLength = 1;
+ transitionLength = 1;
}
- pFromDeck->fadeBeginPos = outroEnd - outroLength;
}
- pFromDeck->fadeEndPos = outroEnd;
- pToDeck->startPos = introStart;
- } else if (introLength > 0 && outroLength <= 0) {
- pFromDeck->fadeBeginPos = outroEnd - introLength;
+ pFromDeck->fadeBeginPos = outroEnd - transitionLength;
pFromDeck->fadeEndPos = outroEnd;
pToDeck->startPos = introStart;
} else {
useFixedFadeTime(pFromDeck, pToDeck, fromDeckPosition, outroEnd, introStart);
}
- break;
- case TransitionMode::FadeAtOutroStart:
+ } break;
+ case TransitionMode::FadeAtOutroStart: {
// Use the outro or intro length for the transition time, whichever is
// shorter. If the outro is longer than the intro, cut off the end
// of the outro.
@@ -1301,40 +1292,35 @@ void AutoDJProcessor::calculateTransition(DeckAttributes* pFromDeck,
// If only the outro or intro length is marked but not both, use the one
// that is marked for the transition time. If neither is marked, fall
// back to the transition time from the spinbox.
- if (outroLength > 0 && introLength > 0) {
- pFromDeck->fadeBeginPos = outroStart;
- if (outroLength > introLength) {
- // Cut off end of outro
- pFromDeck->fadeEndPos = outroStart + introLength;
- } else {
- pFromDeck->fadeEndPos = outroEnd;
+ double transitionLength = outroLength;
+ if (transitionLength > 0) {
+ if (introLength > 0) {
+ if (outroLength > introLength) {
+ // Cut off end of outro
+ transitionLength = introLength;
+ }
}
- pToDeck->startPos = introStart;
- } else if (outroLength > 0 && introLength <= 0) {
- if (outroLength + introStart < pToDeck->fadeBeginPos) {
- pFromDeck->fadeBeginPos = outroStart;
- pFromDeck->fadeEndPos = outroEnd;
- } else {
- // This happens if the toDeck track has no intro set and the
- // outro of the fromDeck track is longer than the whole toDeck
- // track
- outroLength = pToDeck->fadeBeginPos - introStart;
- VERIFY_OR_DEBUG_ASSERT(outroLength > 0) {
+ const double transitionEnd = introStart + transitionLength;
+ if (transitionEnd > pToDeck->fadeBeginPos) {
+ // End intro before next outro starts
+ transitionLength = pToDeck->fadeBeginPos - introStart;
+ VERIFY_OR_DEBUG_ASSERT(transitionLength > 0) {
// We seek to intro start above in this case so this never happens
- outroLength = 1;
+ transitionLength = 1;
}
- pFromDeck->fadeBeginPos = outroStart;
- pFromDeck->fadeEndPos = outroStart + outroLength;
}
+ pFromDeck->fadeBeginPos = outroStart;
+ pFromDeck->fadeEndPos = outroStart + transitionLength;
pToDeck->startPos = introStart;
- } else if (introLength > 0 && outroLength <= 0) {
- pFromDeck->fadeBeginPos = outroEnd - introLength;
+ } else if (introLength > 0) {
+ transitionLength = introLength;
+ pFromDeck->fadeBeginPos = outroEnd - transitionLength;
pFromDeck->fadeEndPos = outroEnd;
pToDeck->startPos = introStart;
} else {
useFixedFadeTime(pFromDeck, pToDeck, fromDeckPosition, outroEnd, introStart);
}
- break;
+ } break;
case TransitionMode::FixedSkipSilence: {
double startPoint;
pToDeck->fadeBeginPos = getLastSoundSecond(pToDeck);
diff --git a/src/mixer/basetrackplayer.cpp b/src/mixer/basetrackplayer.cpp
index 2058d66d6a..ebd7b70fd3 100644
--- a/src/mixer/basetrackplayer.cpp
+++ b/src/mixer/basetrackplayer.cpp
@@ -525,7 +525,9 @@ TrackPointer BaseTrackPlayerImpl::getLoadedTrack() const {
void BaseTrackPlayerImpl::slotCloneDeck() {
Syncable* syncable = m_pEngineMaster->getEngineSync()->pickNonSyncSyncTarget(m_pChannel);
- slotCloneChannel(syncable->getChannel());
+ if (syncable) {
+ slotCloneChannel(syncable->getChannel());
+ }
}
void BaseTrackPlayerImpl::slotCloneFromGroup(const QString& group) {
diff --git a/src/mixer/playerinfo.cpp b/src/mixer/playerinfo.cpp
index 2a9c98e206..47771586fc 100644
--- a/src/mixer/playerinfo.cpp
+++ b/src/mixer/playerinfo.cpp
@@ -42,9 +42,17 @@ PlayerInfo::~PlayerInfo() {
clearControlCache();
}
+PlayerInfo& PlayerInfo::create() {
+ VERIFY_OR_DEBUG_ASSERT(!s_pPlayerInfo) {
+ return *s_pPlayerInfo;
+ }
+ s_pPlayerInfo = new PlayerInfo();
+ return *s_pPlayerInfo;
+}
+
// static
PlayerInfo& PlayerInfo::instance() {
- if (!s_pPlayerInfo) {
+ VERIFY_OR_DEBUG_ASSERT(s_pPlayerInfo) {
s_pPlayerInfo = new PlayerInfo();
}
return *s_pPlayerInfo;
diff --git a/src/mixer/playerinfo.h b/src/mixer/playerinfo.h
index 9a94eb15a6..5aee4fc06c 100644
--- a/src/mixer/playerinfo.h
+++ b/src/mixer/playerinfo.h
@@ -28,6 +28,7 @@
class PlayerInfo : public QObject {
Q_OBJECT
public:
+ static PlayerInfo& create();
static PlayerInfo& instance();
static void destroy();
TrackPointer getTrackInfo(const QString& group);
diff --git a/src/mixxx.cpp b/src/mixxx.cpp
index d4bc6e4d12..869ab53db6 100644
--- a/src/mixxx.cpp
+++ b/src/mixxx.cpp
@@ -321,6 +321,7 @@ void MixxxMainWindow::initialize(QApplication* pApp, const CmdlineArgs& args) {
&PlayerManager::noVinylControlInputConfigured,
this,
&MixxxMainWindow::slotNoVinylControlInputConfigured);
+ PlayerInfo::create();
for (int i = 0; i < kMicrophoneCount; ++i) {
m_pPlayerManager->addMicrophone();
diff --git a/src/test/autodjprocessor_test.cpp b/src/test/autodjprocessor_test.cpp
index 77bad5411c..dfb12f7e23 100644
--- a/src/test/autodjprocessor_test.cpp
+++ b/src/test/autodjprocessor_test.cpp
@@ -1,19 +1,21 @@
-#include <gtest/gtest.h>
+#include "library/autodj/autodjprocessor.h"
+
#include <gmock/gmock.h>
+#include <gtest/gtest.h>
-#include <QString>
#include <QScopedPointer>
+#include <QString>
-#include "test/librarytest.h"
-#include "library/autodj/autodjprocessor.h"
-#include "control/controlpushbutton.h"
-#include "control/controlpotmeter.h"
#include "control/controllinpotmeter.h"
+#include "control/controlpotmeter.h"
+#include "control/controlpushbutton.h"
#include "engine/engine.h"
-#include "mixer/playermanager.h"
#include "mixer/basetrackplayer.h"
-#include "track/track.h"
+#include "mixer/playerinfo.h"
+#include "mixer/playermanager.h"
#include "sources/soundsourceproxy.h"
+#include "test/librarytest.h"
+#include "track/track.h"
using ::testing::_;
using ::testing::Return;
@@ -51,6 +53,8 @@ class FakeDeck : public BaseTrackPlayer {
outroEndPos(ConfigKey(group, "outro_end_position")) {
play.setButtonMode(ControlPushButton::TOGGLE);
repeat.setButtonMode(ControlPushButton::TOGGLE);
+ outroStartPos.set(Cue::kNoPosition);
+ outroEndPos.set(Cue::kNoPosition);
}
void fakeTrackLoadedEvent(TrackPointer pTrack) {
@@ -185,6 +189,7 @@ class AutoDJProcessorTest : public LibraryTest {
}
pPlayerManager.reset(new MockPlayerManager());
+ PlayerInfo::create();
// Setup 4 fake decks.
ON_CALL(*pPlayerManager, getPlayer(QString("[Channel1]")))
@@ -208,6 +213,7 @@ class AutoDJProcessorTest : public LibraryTest {
}
virtual ~AutoDJProcessorTest() {
+ PlayerInfo::destroy();
}
TrackId addTrackToCollection(const QString& trackLocation) {
diff --git a/src/test/signalpathtest.h b/src/test/signalpathtest.h
index d6bd67d070..10d5541651 100644
--- a/src/test/signalpathtest.h
+++ b/src/test/signalpathtest.h
@@ -1,25 +1,25 @@
-#ifndef ENGINEBACKENDTEST_H_
-#define ENGINEBACKENDTEST_H_
+#pragma once
-#include <gtest/gtest.h>
#include <gmock/gmock.h>
+#include <gtest/gtest.h>
-#include <QtDebug>
#include <QTest>
+#include <QtDebug>
-#include "preferences/usersettings.h"
#include "control/controlobject.h"
-#include "mixer/deck.h"
#include "effects/effectsmanager.h"
-#include "engine/enginebuffer.h"
#include "engine/bufferscalers/enginebufferscale.h"
#include "engine/channels/enginechannel.h"
#include "engine/channels/enginedeck.h"
-#include "engine/enginemaster.h"
#include "engine/controls/ratecontrol.h"
+#include "engine/enginebuffer.h"
+#include "engine/enginemaster.h"
#include "engine/sync/enginesync.h"
+#include "mixer/deck.h"
+#include "mixer/playerinfo.h"
#include "mixer/previewdeck.h"
#include "mixer/sampler.h"
+#include "preferences/usersettings.h"
#include "test/mixxxtest.h"
#include "util/defs.h"
#include "util/memory.h"
@@ -94,6 +94,8 @@ class BaseSignalPathTest : public MixxxTest {
m_pEngineSync = m_pEngineMaster->getEngineSync();
ControlObject::set(ConfigKey("[Master]", "enabled"), 1.0);
+
+ PlayerInfo::create();
}
~BaseSignalPathTest() override {
@@ -111,6 +113,7 @@ class BaseSignalPathTest : public MixxxTest {
delete m_pEffectsManager;
delete m_pVisualsManager;
delete m_pNumDecks;
+ PlayerInfo::destroy();
}
void addDeck(EngineDeck* pDeck) {
@@ -234,5 +237,3 @@ class SignalPathTest : public BaseSignalPathTest {
loadTrack(m_pMixerDeck3, pTrack);
}
};
-
-#endif /* ENGINEBACKENDTEST_H_ */