From ba81c2ecd597b26737f08d7151370ca581d6895b Mon Sep 17 00:00:00 2001 From: philippe44 Date: Sun, 9 Apr 2023 10:30:56 -0700 Subject: [PATCH] fix plop when switchign track (still need to fix it when seeking) - release --- components/spotify/Shim.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/spotify/Shim.cpp b/components/spotify/Shim.cpp index 9164ef8d..8615c78d 100644 --- a/components/spotify/Shim.cpp +++ b/components/spotify/Shim.cpp @@ -39,6 +39,7 @@ class chunkManager : public bell::Task { public: std::atomic isRunning = true; std::atomic isPaused = true; + std::atomic discard = true; chunkManager(std::shared_ptr centralAudioBuffer, std::function trackHandler, std::function dataHandler); void teardown(); @@ -88,10 +89,11 @@ void chunkManager::runTask() { if (lastHash != chunk->trackHash) { CSPOT_LOG(info, "hash update %x => %x", lastHash, chunk->trackHash); lastHash = chunk->trackHash; + discard = false; trackHandler(); } - dataHandler(chunk->pcmData, chunk->pcmSize); + if (!discard) dataHandler(chunk->pcmData, chunk->pcmSize); } } @@ -223,6 +225,7 @@ esp_err_t cspotPlayer::handlePOST(httpd_req_t *request) { void cspotPlayer::eventHandler(std::unique_ptr event) { switch (event->eventType) { case cspot::SpircHandler::EventType::PLAYBACK_START: { + chunker->discard = true; centralAudioBuffer->clearBuffer(); // we are not playing anymore