Skip to content

Commit 17a5f6e

Browse files
committed
AutoDJ: Reset AutoDJ when deck orientation changes
When deck orientation changes, disable and then enable AutoDJ in case the program is now in an invalid state. Fixes mixxxdj#15962 Signed-off-by: Owen Williams <owilliams@mixxx.org>
1 parent 74ba0f6 commit 17a5f6e

2 files changed

Lines changed: 32 additions & 0 deletions

File tree

src/library/autodj/autodjprocessor.cpp

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,7 @@ DeckAttributes::DeckAttributes(int index,
5454
m_outroStartPos.connectValueChanged(this, &DeckAttributes::slotOutroStartPositionChanged);
5555
m_outroEndPos.connectValueChanged(this, &DeckAttributes::slotOutroEndPositionChanged);
5656
m_rateRatio.connectValueChanged(this, &DeckAttributes::slotRateChanged);
57+
m_orientation.connectValueChanged(this, &DeckAttributes::slotOrientationChanged);
5758
}
5859

5960
DeckAttributes::~DeckAttributes() {
@@ -101,6 +102,11 @@ void DeckAttributes::slotRateChanged(double v) {
101102
emit rateChanged(this);
102103
}
103104

105+
void DeckAttributes::slotOrientationChanged(double v) {
106+
Q_UNUSED(v);
107+
emit orientationChanged(this);
108+
}
109+
104110
TrackPointer DeckAttributes::getLoadedTrack() const {
105111
return m_pPlayer != nullptr ? m_pPlayer->getLoadedTrack() : TrackPointer();
106112
}
@@ -529,6 +535,16 @@ AutoDJProcessor::AutoDJError AutoDJProcessor::toggleAutoDJ(bool enable) {
529535
&DeckAttributes::rateChanged,
530536
this,
531537
&AutoDJProcessor::playerRateChanged);
538+
539+
connect(pLeftDeck,
540+
&DeckAttributes::orientationChanged,
541+
this,
542+
&AutoDJProcessor::playerOrientationChanged);
543+
connect(pRightDeck,
544+
&DeckAttributes::orientationChanged,
545+
this,
546+
&AutoDJProcessor::playerOrientationChanged);
547+
532548
connect(m_pAutoDJTableModel,
533549
&PlaylistTableModel::firstTrackChanged,
534550
this,
@@ -1667,6 +1683,19 @@ void AutoDJProcessor::playerRateChanged(DeckAttributes* pAttributes) {
16671683
calculateTransition(fromDeck, getOtherDeck(fromDeck), false);
16681684
}
16691685

1686+
void AutoDJProcessor::playerOrientationChanged(DeckAttributes* pAttributes) {
1687+
if constexpr (sDebug) {
1688+
qDebug() << this << "playerOrientationChanged" << pAttributes->group;
1689+
}
1690+
1691+
if (m_eState != ADJ_DISABLED) {
1692+
// Disable and Enable auto DJ. We will likely fail to enable auto DJ
1693+
// but that will pop up an error to explain the situation to the user.
1694+
toggleAutoDJ(false);
1695+
toggleAutoDJ(true);
1696+
}
1697+
}
1698+
16701699
void AutoDJProcessor::playlistFirstTrackChanged() {
16711700
if constexpr (sDebug) {
16721701
qDebug() << this << "playlistFirstTrackChanged";

src/library/autodj/autodjprocessor.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -105,6 +105,7 @@ class DeckAttributes : public QObject {
105105
void loadingTrack(DeckAttributes* pDeck, TrackPointer pNewTrack, TrackPointer pOldTrack);
106106
void playerEmpty(DeckAttributes* pDeck);
107107
void rateChanged(DeckAttributes* pDeck);
108+
void orientationChanged(DeckAttributes* pDeck);
108109

109110
private slots:
110111
void slotPlayPosChanged(double v);
@@ -117,6 +118,7 @@ class DeckAttributes : public QObject {
117118
void slotLoadingTrack(TrackPointer pNewTrack, TrackPointer pOldTrack);
118119
void slotPlayerEmpty();
119120
void slotRateChanged(double v);
121+
void slotOrientationChanged(double v);
120122

121123
public:
122124
int index;
@@ -223,6 +225,7 @@ class AutoDJProcessor : public QObject {
223225
void playerLoadingTrack(DeckAttributes* pDeck, TrackPointer pNewTrack, TrackPointer pOldTrack);
224226
void playerEmpty(DeckAttributes* pDeck);
225227
void playerRateChanged(DeckAttributes* pDeck);
228+
void playerOrientationChanged(DeckAttributes* pDeck);
226229
void playlistFirstTrackChanged();
227230

228231
void controlEnableChangeRequest(double value);

0 commit comments

Comments
 (0)