|
@@ -587,8 +587,9 @@ bool TrackQueue::isFinished() {
|
|
|
return currentTracksIndex >= currentTracks.size() - 1;
|
|
|
}
|
|
|
|
|
|
-void TrackQueue::updateTracks(uint32_t requestedPosition, bool initial) {
|
|
|
+bool TrackQueue::updateTracks(uint32_t requestedPosition, bool initial) {
|
|
|
std::scoped_lock lock(tracksMutex);
|
|
|
+ bool cleared = true;
|
|
|
|
|
|
if (initial) {
|
|
|
// Clear preloaded tracks
|
|
@@ -609,13 +610,28 @@ void TrackQueue::updateTracks(uint32_t requestedPosition, bool initial) {
|
|
|
|
|
|
playableSemaphore->give();
|
|
|
} else {
|
|
|
- // Clear preloaded tracks
|
|
|
- preloadedTracks.clear();
|
|
|
-
|
|
|
// Copy requested track list
|
|
|
currentTracks = playbackState->remoteTracks;
|
|
|
|
|
|
- // Push a song on the preloaded queue
|
|
|
- queueNextTrack(0, requestedPosition);
|
|
|
+ // try to not re-load track if we are still loading it
|
|
|
+ if (preloadedTracks[0]->loading) {
|
|
|
+ // remove everything except first track
|
|
|
+ preloadedTracks.erase(preloadedTracks.begin() + 1, preloadedTracks.end());
|
|
|
+
|
|
|
+ // Push a song on the preloaded queue
|
|
|
+ CSPOT_LOG(info, "Keeping current track");
|
|
|
+ queueNextTrack(1);
|
|
|
+
|
|
|
+ cleared = false;
|
|
|
+ } else {
|
|
|
+ // Clear preloaded tracks
|
|
|
+ preloadedTracks.clear();
|
|
|
+
|
|
|
+ // Push a song on the preloaded queue
|
|
|
+ CSPOT_LOG(info, "Re-loading current track");
|
|
|
+ queueNextTrack(0, requestedPosition);
|
|
|
+ }
|
|
|
}
|
|
|
+
|
|
|
+ return cleared;
|
|
|
}
|