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.cpp18
1 files changed, 15 insertions, 3 deletions
diff --git a/src/audio/audio_fsm.cpp b/src/audio/audio_fsm.cpp
index 3bd4d396..90bfd60b 100644
--- a/src/audio/audio_fsm.cpp
+++ b/src/audio/audio_fsm.cpp
@@ -50,6 +50,12 @@ std::shared_ptr<IAudioOutput> AudioState::sOutput;
std::optional<database::TrackId> AudioState::sCurrentTrack;
+void AudioState::react(const system_fsm::KeyLockChanged& ev) {
+ if (ev.locking && sServices) {
+ sServices->nvs().AmpCurrentVolume(sOutput->GetVolume());
+ }
+}
+
void AudioState::react(const StepUpVolume& ev) {
if (sOutput->AdjustVolumeUp()) {
events::Ui().Dispatch(VolumeChanged{});
@@ -63,10 +69,10 @@ void AudioState::react(const StepDownVolume& ev) {
}
void AudioState::react(const system_fsm::HasPhonesChanged& ev) {
- if (ev.falling) {
- // ESP_LOGI(kTag, "headphones in!");
+ if (ev.has_headphones) {
+ ESP_LOGI(kTag, "headphones in!");
} else {
- // ESP_LOGI(kTag, "headphones out!");
+ ESP_LOGI(kTag, "headphones out!");
}
}
@@ -186,6 +192,12 @@ void Playback::exit() {
events::Ui().Dispatch(PlaybackFinished{});
}
+void Playback::react(const system_fsm::HasPhonesChanged& ev) {
+ if (!ev.has_headphones) {
+ transit<Standby>();
+ }
+}
+
void Playback::react(const QueueUpdate& ev) {
if (!ev.current_changed) {
return;