diff --git a/src/mixer/basetrackplayer.cpp b/src/mixer/basetrackplayer.cpp index 86055faaf83..5c67fecde6f 100644 --- a/src/mixer/basetrackplayer.cpp +++ b/src/mixer/basetrackplayer.cpp @@ -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(); diff --git a/src/mixer/playerinfo.cpp b/src/mixer/playerinfo.cpp index 93e43db93a9..f1de6ea3ae6 100644 --- a/src/mixer/playerinfo.cpp +++ b/src/mixer/playerinfo.cpp @@ -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); + } } } @@ -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); + } } }