Skip to content

Commit

Permalink
Merge pull request mixxxdj#12909 from Bacadam/fix_8956
Browse files Browse the repository at this point in the history
Synchronize AutoDJ next deck with top track in queue
  • Loading branch information
ronso0 authored Aug 20, 2024
2 parents 6605e4d + 7aaa7eb commit 886efbe
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 0 deletions.
20 changes: 20 additions & 0 deletions src/library/autodj/autodjprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -535,6 +535,10 @@ AutoDJProcessor::AutoDJError AutoDJProcessor::toggleAutoDJ(bool enable) {
&DeckAttributes::rateChanged,
this,
&AutoDJProcessor::playerRateChanged);
connect(m_pAutoDJTableModel,
&PlaylistTableModel::firstTrackChanged,
this,
&AutoDJProcessor::playlistFirstTrackChanged);

if (!leftDeckPlaying && !rightDeckPlaying) {
// Both decks are stopped. Load a track into deck 1 and start it
Expand Down Expand Up @@ -1666,6 +1670,22 @@ void AutoDJProcessor::playerRateChanged(DeckAttributes* pAttributes) {
calculateTransition(fromDeck, getOtherDeck(fromDeck), false);
}

void AutoDJProcessor::playlistFirstTrackChanged() {
if constexpr (sDebug) {
qDebug() << this << "playlistFirstTrackChanged";
}
if (m_eState != ADJ_DISABLED) {
DeckAttributes* pLeftDeck = getLeftDeck();
DeckAttributes* pRightDeck = getRightDeck();

if (!pLeftDeck->isPlaying()) {
loadNextTrackFromQueue(*pLeftDeck);
} else if (!pRightDeck->isPlaying()) {
loadNextTrackFromQueue(*pRightDeck);
}
}
}

void AutoDJProcessor::setTransitionTime(int time) {
if constexpr (sDebug) {
qDebug() << this << "setTransitionTime" << time;
Expand Down
1 change: 1 addition & 0 deletions src/library/autodj/autodjprocessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,7 @@ class AutoDJProcessor : public QObject {
void playerLoadingTrack(DeckAttributes* pDeck, TrackPointer pNewTrack, TrackPointer pOldTrack);
void playerEmpty(DeckAttributes* pDeck);
void playerRateChanged(DeckAttributes* pDeck);
void playlistFirstTrackChanged();

void controlEnableChangeRequest(double value);
void controlFadeNow(double value);
Expand Down
8 changes: 8 additions & 0 deletions src/library/playlisttablemodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,10 @@ void PlaylistTableModel::removeTracks(const QModelIndexList& indices) {
m_pTrackCollectionManager->internalCollection()->getPlaylistDAO().removeTracksFromPlaylist(
m_iPlaylistId,
std::move(trackPositions));

if (trackPositions.contains(1)) {
emit firstTrackChanged();
}
}

void PlaylistTableModel::moveTrack(const QModelIndex& sourceIndex,
Expand All @@ -283,6 +287,10 @@ void PlaylistTableModel::moveTrack(const QModelIndex& sourceIndex,
}

m_pTrackCollectionManager->internalCollection()->getPlaylistDAO().moveTrack(m_iPlaylistId, oldPosition, newPosition);

if (oldPosition == 1 || newPosition == 1) {
emit firstTrackChanged();
}
}

bool PlaylistTableModel::isLocked() {
Expand Down
3 changes: 3 additions & 0 deletions src/library/playlisttablemodel.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ class PlaylistTableModel final : public TrackSetTableModel {
private slots:
void playlistsChanged(const QSet<int>& playlistIds);

signals:
void firstTrackChanged();

private:
void initSortColumnMapping() override;

Expand Down

0 comments on commit 886efbe

Please sign in to comment.