From 28651fa7e1d6a90af65d268e6515ed1d2e3b6037 Mon Sep 17 00:00:00 2001 From: jacqueline Date: Wed, 21 Feb 2024 14:13:19 +1100 Subject: [PATCH] Wait for the sink buffer to drain before stopping playback --- src/audio/audio_fsm.cpp | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/src/audio/audio_fsm.cpp b/src/audio/audio_fsm.cpp index 0119855a..ea0315eb 100644 --- a/src/audio/audio_fsm.cpp +++ b/src/audio/audio_fsm.cpp @@ -366,6 +366,12 @@ void Playback::react(const internal::InputFileFinished& ev) { ESP_LOGI(kTag, "finished playing file"); sServices->track_queue().finish(); if (!sServices->track_queue().current()) { + for (int i = 0; i < 20; i++) { + if (xStreamBufferIsEmpty(sDrainBuffer)) { + break; + } + vTaskDelay(pdMS_TO_TICKS(200)); + } transit(); } }