mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-06 19:47:02 +03:00
fix Spotify queue modifications - release
This commit is contained in:
@@ -53,6 +53,7 @@ private:
|
|||||||
std::atomic<states> state;
|
std::atomic<states> state;
|
||||||
std::string credentials;
|
std::string credentials;
|
||||||
bool zeroConf;
|
bool zeroConf;
|
||||||
|
std::atomic<bool> flushed = false, notify = true;
|
||||||
|
|
||||||
int startOffset, volume = 0, bitrate = 160;
|
int startOffset, volume = 0, bitrate = 160;
|
||||||
httpd_handle_t serverHandle;
|
httpd_handle_t serverHandle;
|
||||||
@@ -60,6 +61,7 @@ private:
|
|||||||
cspot_cmd_cb_t cmdHandler;
|
cspot_cmd_cb_t cmdHandler;
|
||||||
cspot_data_cb_t dataHandler;
|
cspot_data_cb_t dataHandler;
|
||||||
std::string lastTrackId;
|
std::string lastTrackId;
|
||||||
|
cspot::TrackInfo trackInfo;
|
||||||
|
|
||||||
std::shared_ptr<cspot::LoginBlob> blob;
|
std::shared_ptr<cspot::LoginBlob> blob;
|
||||||
std::unique_ptr<cspot::SpircHandler> spirc;
|
std::unique_ptr<cspot::SpircHandler> spirc;
|
||||||
@@ -206,11 +208,13 @@ void cspotPlayer::eventHandler(std::unique_ptr<cspot::SpircHandler::Event> event
|
|||||||
trackStatus = TRACK_INIT;
|
trackStatus = TRACK_INIT;
|
||||||
// memorize position for when track's beginning will be detected
|
// memorize position for when track's beginning will be detected
|
||||||
startOffset = std::get<int>(event->data);
|
startOffset = std::get<int>(event->data);
|
||||||
|
notify = !flushed;
|
||||||
|
flushed = false;
|
||||||
// Spotify servers do not send volume at connection
|
// Spotify servers do not send volume at connection
|
||||||
spirc->setRemoteVolume(volume);
|
spirc->setRemoteVolume(volume);
|
||||||
|
|
||||||
cmdHandler(CSPOT_START, 44100);
|
cmdHandler(CSPOT_START, 44100);
|
||||||
CSPOT_LOG(info, "(re)start playing");
|
CSPOT_LOG(info, "(re)start playing at %d", startOffset);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cspot::SpircHandler::EventType::PLAY_PAUSE: {
|
case cspot::SpircHandler::EventType::PLAY_PAUSE: {
|
||||||
@@ -219,16 +223,14 @@ void cspotPlayer::eventHandler(std::unique_ptr<cspot::SpircHandler::Event> event
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
case cspot::SpircHandler::EventType::TRACK_INFO: {
|
case cspot::SpircHandler::EventType::TRACK_INFO: {
|
||||||
auto trackInfo = std::get<cspot::TrackInfo>(event->data);
|
trackInfo = std::get<cspot::TrackInfo>(event->data);
|
||||||
cmdHandler(CSPOT_TRACK_INFO, trackInfo.duration, startOffset, trackInfo.artist.c_str(),
|
|
||||||
trackInfo.album.c_str(), trackInfo.name.c_str(), trackInfo.imageUrl.c_str());
|
|
||||||
spirc->updatePositionMs(startOffset);
|
|
||||||
startOffset = 0;
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
case cspot::SpircHandler::EventType::FLUSH:
|
||||||
|
flushed = true;
|
||||||
|
__attribute__ ((fallthrough));
|
||||||
case cspot::SpircHandler::EventType::NEXT:
|
case cspot::SpircHandler::EventType::NEXT:
|
||||||
case cspot::SpircHandler::EventType::PREV:
|
case cspot::SpircHandler::EventType::PREV: {
|
||||||
case cspot::SpircHandler::EventType::FLUSH: {
|
|
||||||
cmdHandler(CSPOT_FLUSH);
|
cmdHandler(CSPOT_FLUSH);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -411,8 +413,13 @@ void cspotPlayer::runTask() {
|
|||||||
uint32_t started;
|
uint32_t started;
|
||||||
cmdHandler(CSPOT_QUERY_STARTED, &started);
|
cmdHandler(CSPOT_QUERY_STARTED, &started);
|
||||||
if (started) {
|
if (started) {
|
||||||
CSPOT_LOG(info, "next track's audio has reached DAC");
|
CSPOT_LOG(info, "next track's audio has reached DAC (offset %d)", startOffset);
|
||||||
spirc->notifyAudioReachedPlayback();
|
if (notify) spirc->notifyAudioReachedPlayback();
|
||||||
|
else notify = true;
|
||||||
|
cmdHandler(CSPOT_TRACK_INFO, trackInfo.duration, startOffset, trackInfo.artist.c_str(),
|
||||||
|
trackInfo.album.c_str(), trackInfo.name.c_str(), trackInfo.imageUrl.c_str());
|
||||||
|
spirc->updatePositionMs(startOffset);
|
||||||
|
startOffset = 0;
|
||||||
trackStatus = TRACK_STREAM;
|
trackStatus = TRACK_STREAM;
|
||||||
}
|
}
|
||||||
} else if (trackStatus == TRACK_END) {
|
} else if (trackStatus == TRACK_END) {
|
||||||
|
|||||||
@@ -204,8 +204,13 @@ void SpircHandler::handleFrame(std::vector<uint8_t>& data) {
|
|||||||
CSPOT_LOG(debug, "Got replace frame");
|
CSPOT_LOG(debug, "Got replace frame");
|
||||||
playbackState->syncWithRemote();
|
playbackState->syncWithRemote();
|
||||||
|
|
||||||
trackQueue->updateTracks(playbackState->remoteFrame.state.position_ms,
|
// 1st track is the current one, but update the position
|
||||||
false);
|
trackQueue->updateTracks(
|
||||||
|
playbackState->remoteFrame.state.position_ms +
|
||||||
|
ctx->timeProvider->getSyncedTimestamp() -
|
||||||
|
playbackState->innerFrame.state.position_measured_at,
|
||||||
|
false);
|
||||||
|
|
||||||
this->notify();
|
this->notify();
|
||||||
|
|
||||||
sendEvent(EventType::FLUSH);
|
sendEvent(EventType::FLUSH);
|
||||||
|
|||||||
Reference in New Issue
Block a user