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

Wrong current Track fix #4041

Merged
merged 4 commits into from
Jul 5, 2021
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
2 changes: 2 additions & 0 deletions src/mixer/basetrackplayer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,8 @@ TrackPointer BaseTrackPlayerImpl::unloadTrack() {
return TrackPointer();
}

PlayerInfo::instance().setTrackInfo(getGroup(), TrackPointer());

// Save the loops that are currently set in a loop cue. If no loop cue is
// currently on the track, then create a new one.
double loopStart = m_pLoopInPoint->get();
Expand Down
25 changes: 18 additions & 7 deletions src/mixer/playerinfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,21 +56,26 @@ TrackPointer PlayerInfo::getTrackInfo(const QString& group) {
return m_loadedTrackMap.value(group);
}

void PlayerInfo::setTrackInfo(const QString& group, const TrackPointer& track) {
void PlayerInfo::setTrackInfo(const QString& group, const TrackPointer& pTrack) {
TrackPointer pOld;
{ // Scope
QMutexLocker locker(&m_mutex);
pOld = m_loadedTrackMap.value(group);
m_loadedTrackMap.insert(group, track);
m_loadedTrackMap.insert(group, pTrack);
}
if (pOld) {
emit trackUnloaded(group, pOld);
}
emit trackLoaded(group, track);
if (pTrack) {
emit trackLoaded(group, pTrack);

if (m_currentlyPlayingDeck >= 0 &&
group == PlayerManager::groupForDeck(m_currentlyPlayingDeck)) {
emit currentPlayingTrackChanged(track);
updateCurrentPlayingDeck();

int playingDeck = m_currentlyPlayingDeck;
if (playingDeck >= 0 &&
group == PlayerManager::groupForDeck(playingDeck)) {
emit currentPlayingTrackChanged(pTrack);
}
}
}

Expand Down Expand Up @@ -166,7 +171,13 @@ void PlayerInfo::updateCurrentPlayingDeck() {
int oldDeck = m_currentlyPlayingDeck.fetchAndStoreRelease(maxDeck);
if (maxDeck != oldDeck) {
emit currentPlayingDeckChanged(maxDeck);
emit currentPlayingTrackChanged(getCurrentPlayingTrack());
// Note: When starting Auto-DJ "play" might be processed before a new
// is track is fully loaded. currentPlayingTrackChanged() is then emitted
// after setTrackInfo().
TrackPointer pTrack = getCurrentPlayingTrack();
if (pTrack) {
emit currentPlayingTrackChanged(pTrack);
}
}
}

Expand Down