summaryrefslogtreecommitdiff
path: root/src/audio/audio_fsm.cpp
diff options
context:
space:
mode:
authorjacqueline <me@jacqueline.id.au>2024-02-21 14:13:19 +1100
committerjacqueline <me@jacqueline.id.au>2024-02-21 14:13:19 +1100
commit28651fa7e1d6a90af65d268e6515ed1d2e3b6037 (patch)
treedacc7c0d7eefeec98ee187412e4caa6e2220e4b1 /src/audio/audio_fsm.cpp
parent29a246a7334c0a298053991f37d22e19de936ad9 (diff)
downloadtangara-fw-28651fa7e1d6a90af65d268e6515ed1d2e3b6037.tar.gz
Wait for the sink buffer to drain before stopping playback
Diffstat (limited to 'src/audio/audio_fsm.cpp')
-rw-r--r--src/audio/audio_fsm.cpp6
1 files changed, 6 insertions, 0 deletions
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<Standby>();
}
}