Browse Source

sync with upstream/cspot

philippe44 1 year ago
parent
commit
5c90086bbd

+ 1 - 0
components/spotify/cspot/bell/main/platform/linux/MDNSService.cpp

@@ -5,6 +5,7 @@
 #include <unistd.h>
 #include <cstring>
 #include <vector>
+#include <mutex>
 
 #if __has_include("avahi-client/client.h")
 #include <avahi-client/client.h>

+ 7 - 5
components/spotify/cspot/src/SpircHandler.cpp

@@ -201,21 +201,23 @@ void SpircHandler::handleFrame(std::vector<uint8_t>& data) {
       break;
     }
     case MessageType_kMessageTypeReplace: {
-      CSPOT_LOG(debug, "Got replace frame %d", playbackState->remoteTracks.size());
+      CSPOT_LOG(debug, "Got replace frame %d",
+                playbackState->remoteTracks.size());
       playbackState->syncWithRemote();
 
       // 1st track is the current one, but update the position
       bool cleared = trackQueue->updateTracks(
           playbackState->remoteFrame.state.position_ms +
-          ctx->timeProvider->getSyncedTimestamp() -
-          playbackState->innerFrame.state.position_measured_at);
+              ctx->timeProvider->getSyncedTimestamp() -
+              playbackState->innerFrame.state.position_measured_at,
+          false);
 
       this->notify();
 
       // need to re-load all if streaming track is completed
       if (cleared) {
-          sendEvent(EventType::FLUSH);
-          trackPlayer->resetState();
+        sendEvent(EventType::FLUSH);
+        trackPlayer->resetState();
       }
       break;
     }

+ 8 - 8
components/spotify/cspot/src/TrackQueue.cpp

@@ -609,16 +609,16 @@ bool TrackQueue::updateTracks(uint32_t requestedPosition, bool initial) {
 
     playableSemaphore->give();
   } else if (preloadedTracks[0]->loading) {
-      // try to not re-load track if we are still loading it
-   
-      // remove everything except first track
-      preloadedTracks.erase(preloadedTracks.begin() + 1, preloadedTracks.end());
+    // try to not re-load track if we are still loading it
 
-      // Push a song on the preloaded queue
-      CSPOT_LOG(info, "Keeping current track %d", currentTracksIndex);
-      queueNextTrack(1);
+    // 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 %d", currentTracksIndex);
+    queueNextTrack(1);
 
-      cleared = false;
+    cleared = false;
   } else {
     // Clear preloaded tracks
     preloadedTracks.clear();