Skip to content

Commit

Permalink
attempt to fix cspot track issues - release
Browse files Browse the repository at this point in the history
  • Loading branch information
philippe44 committed Nov 14, 2023
1 parent d31697e commit a9ca4c4
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 21 deletions.
2 changes: 1 addition & 1 deletion components/services/services.c
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ void services_init(void) {
}
#endif

// set potential power GPIO on chip first in case expanders are power using these
// set potential power GPIO on chip first in case expanders are powered using these
parse_set_GPIO(set_chip_power_gpio);

// shared I2C bus
Expand Down
2 changes: 1 addition & 1 deletion components/spotify/cspot/src/SpircHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ void SpircHandler::handleFrame(std::vector<uint8_t>& data) {
break;
}
case MessageType_kMessageTypeReplace: {
CSPOT_LOG(debug, "Got replace frame");
CSPOT_LOG(debug, "Got replace frame %d", playbackState->remoteTracks.size());
playbackState->syncWithRemote();

// 1st track is the current one, but update the position
Expand Down
33 changes: 14 additions & 19 deletions components/spotify/cspot/src/TrackQueue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -591,15 +591,14 @@ bool TrackQueue::updateTracks(uint32_t requestedPosition, bool initial) {
std::scoped_lock lock(tracksMutex);
bool cleared = true;

// Copy requested track list
currentTracks = playbackState->remoteTracks;
currentTracksIndex = playbackState->innerFrame.state.playing_track_index;

if (initial) {
// Clear preloaded tracks
preloadedTracks.clear();

// Copy requested track list
currentTracks = playbackState->remoteTracks;

currentTracksIndex = playbackState->innerFrame.state.playing_track_index;

if (currentTracksIndex < currentTracks.size()) {
// Push a song on the preloaded queue
queueNextTrack(0, requestedPosition);
Expand All @@ -609,28 +608,24 @@ bool TrackQueue::updateTracks(uint32_t requestedPosition, bool initial) {
notifyPending = true;

playableSemaphore->give();
} else {
// Copy requested track list
currentTracks = playbackState->remoteTracks;

// try to not re-load track if we are still loading it
if (preloadedTracks[0]->loading) {
} 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());

// Push a song on the preloaded queue
CSPOT_LOG(info, "Keeping current track");
CSPOT_LOG(info, "Keeping current track %d", currentTracksIndex);
queueNextTrack(1);

cleared = false;
} else {
// Clear preloaded tracks
preloadedTracks.clear();
} else {
// Clear preloaded tracks
preloadedTracks.clear();

// Push a song on the preloaded queue
CSPOT_LOG(info, "Re-loading current track");
queueNextTrack(0, requestedPosition);
}
// Push a song on the preloaded queue
CSPOT_LOG(info, "Re-loading current track");
queueNextTrack(0, requestedPosition);
}

return cleared;
Expand Down

0 comments on commit a9ca4c4

Please sign in to comment.