mirror of
https://github.com/sle118/squeezelite-esp32.git
synced 2025-12-09 13:07:03 +03:00
fix plop when switchign track (still need to fix it when seeking) - release
This commit is contained in:
@@ -39,6 +39,7 @@ class chunkManager : public bell::Task {
|
|||||||
public:
|
public:
|
||||||
std::atomic<bool> isRunning = true;
|
std::atomic<bool> isRunning = true;
|
||||||
std::atomic<bool> isPaused = true;
|
std::atomic<bool> isPaused = true;
|
||||||
|
std::atomic<bool> discard = true;
|
||||||
chunkManager(std::shared_ptr<bell::CentralAudioBuffer> centralAudioBuffer, std::function<void()> trackHandler,
|
chunkManager(std::shared_ptr<bell::CentralAudioBuffer> centralAudioBuffer, std::function<void()> trackHandler,
|
||||||
std::function<void(const uint8_t*, size_t)> dataHandler);
|
std::function<void(const uint8_t*, size_t)> dataHandler);
|
||||||
void teardown();
|
void teardown();
|
||||||
@@ -88,10 +89,11 @@ void chunkManager::runTask() {
|
|||||||
if (lastHash != chunk->trackHash) {
|
if (lastHash != chunk->trackHash) {
|
||||||
CSPOT_LOG(info, "hash update %x => %x", lastHash, chunk->trackHash);
|
CSPOT_LOG(info, "hash update %x => %x", lastHash, chunk->trackHash);
|
||||||
lastHash = chunk->trackHash;
|
lastHash = chunk->trackHash;
|
||||||
|
discard = false;
|
||||||
trackHandler();
|
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<cspot::SpircHandler::Event> event) {
|
void cspotPlayer::eventHandler(std::unique_ptr<cspot::SpircHandler::Event> event) {
|
||||||
switch (event->eventType) {
|
switch (event->eventType) {
|
||||||
case cspot::SpircHandler::EventType::PLAYBACK_START: {
|
case cspot::SpircHandler::EventType::PLAYBACK_START: {
|
||||||
|
chunker->discard = true;
|
||||||
centralAudioBuffer->clearBuffer();
|
centralAudioBuffer->clearBuffer();
|
||||||
|
|
||||||
// we are not playing anymore
|
// we are not playing anymore
|
||||||
|
|||||||
Reference in New Issue
Block a user