summaryrefslogtreecommitdiff
path: root/src/audio/audio_fsm.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio/audio_fsm.cpp')
-rw-r--r--src/audio/audio_fsm.cpp12
1 files changed, 11 insertions, 1 deletions
diff --git a/src/audio/audio_fsm.cpp b/src/audio/audio_fsm.cpp
index cd36b398..6cca8211 100644
--- a/src/audio/audio_fsm.cpp
+++ b/src/audio/audio_fsm.cpp
@@ -133,6 +133,12 @@ void Standby::react(const QueueUpdate& ev) {
sFileSource->SetPath(db->GetTrackPath(*current_track));
}
+void Standby::react(const TogglePlayPause& ev) {
+ if (sCurrentTrack) {
+ transit<Playback>();
+ }
+}
+
void Playback::entry() {
ESP_LOGI(kTag, "beginning playback");
sOutput->SetInUse(true);
@@ -142,7 +148,7 @@ void Playback::exit() {
ESP_LOGI(kTag, "finishing playback");
// TODO(jacqueline): Second case where it's useful to wait for the i2s buffer
// to drain.
- vTaskDelay(pdMS_TO_TICKS(250));
+ vTaskDelay(pdMS_TO_TICKS(10));
sOutput->SetInUse(false);
events::System().Dispatch(PlaybackFinished{});
@@ -170,6 +176,10 @@ void Playback::react(const QueueUpdate& ev) {
sFileSource->SetPath(db->GetTrackPath(*current_track));
}
+void Playback::react(const TogglePlayPause& ev) {
+ transit<Standby>();
+}
+
void Playback::react(const PlaybackUpdate& ev) {
ESP_LOGI(kTag, "elapsed: %lu, total: %lu", ev.seconds_elapsed,
ev.seconds_total);