Skip to content

Commit

Permalink
Merge pull request #4041 from daschuer/lp1933991
Browse files Browse the repository at this point in the history
Wrong current Track fix
  • Loading branch information
uklotzde committed Jul 5, 2021
2 parents b5a8dcd + 01fa486 commit 0a6f108
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 7 deletions.
2 changes: 2 additions & 0 deletions src/mixer/basetrackplayer.cpp
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
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

0 comments on commit 0a6f108

Please sign in to comment.