From 37c41e5daf19dcac0b148a5d02792f4c15c81078 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 30 Jun 2021 00:37:33 +0200 Subject: [PATCH 1/4] Notify PlayerInfo class when a track is unloaded --- src/mixer/basetrackplayer.cpp | 2 ++ src/mixer/playerinfo.cpp | 8 +++++++- 2 files changed, 9 insertions(+), 1 deletion(-) 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..e763230572b 100644 --- a/src/mixer/playerinfo.cpp +++ b/src/mixer/playerinfo.cpp @@ -166,7 +166,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 + // later setTrackInfo() + TrackPointer pTrack = getCurrentPlayingTrack(); + if (pTrack) { + emit currentPlayingTrackChanged(pTrack); + } } } From c28cc0794c4e8b0057bd356f25945f3c986f1773 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Wed, 30 Jun 2021 01:01:02 +0200 Subject: [PATCH 2/4] Update m_currentlyPlayingDeck before emitting a changed signal --- src/mixer/playerinfo.cpp | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/src/mixer/playerinfo.cpp b/src/mixer/playerinfo.cpp index e763230572b..3bddb25332e 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); + } } } From 7d2e658519b2ab8a1883f1c7ffc82fb9420fc904 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 2 Jul 2021 08:16:50 +0200 Subject: [PATCH 3/4] improve comment Co-authored-by: Jan Holthuis --- src/mixer/playerinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mixer/playerinfo.cpp b/src/mixer/playerinfo.cpp index 3bddb25332e..a12a2cc7fb5 100644 --- a/src/mixer/playerinfo.cpp +++ b/src/mixer/playerinfo.cpp @@ -173,7 +173,7 @@ void PlayerInfo::updateCurrentPlayingDeck() { emit currentPlayingDeckChanged(maxDeck); // Note: When starting Auto-DJ "play" might be processed before a new // is track is fully loaded. currentPlayingTrackChanged() is then emitted - // later setTrackInfo() + // after setTrackInfo(). TrackPointer pTrack = getCurrentPlayingTrack(); if (pTrack) { emit currentPlayingTrackChanged(pTrack); From 01fa486326e565dcf3cfdf62784d0e5ed7a7371c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Sch=C3=BCrmann?= Date: Fri, 2 Jul 2021 09:26:13 +0200 Subject: [PATCH 4/4] Update playerinfo.cpp --- src/mixer/playerinfo.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mixer/playerinfo.cpp b/src/mixer/playerinfo.cpp index a12a2cc7fb5..f1de6ea3ae6 100644 --- a/src/mixer/playerinfo.cpp +++ b/src/mixer/playerinfo.cpp @@ -173,7 +173,7 @@ void PlayerInfo::updateCurrentPlayingDeck() { emit currentPlayingDeckChanged(maxDeck); // Note: When starting Auto-DJ "play" might be processed before a new // is track is fully loaded. currentPlayingTrackChanged() is then emitted - // after setTrackInfo(). + // after setTrackInfo(). TrackPointer pTrack = getCurrentPlayingTrack(); if (pTrack) { emit currentPlayingTrackChanged(pTrack);