Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Synchronize AutoDJ next deck with top track in queue #12909

Merged
merged 6 commits into from
Aug 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions src/library/autodj/autodjprocessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,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 @@ -1665,6 +1669,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 @@ -250,6 +250,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 @@ -275,6 +279,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 @@ -38,6 +38,9 @@ class PlaylistTableModel final : public TrackSetTableModel {
private slots:
void playlistsChanged(const QSet<int>& playlistIds);

signals:
void firstTrackChanged();

private:
void initSortColumnMapping() override;

Expand Down
Loading