diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-12-18 11:05:44 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-12-18 11:05:44 +1100 |
| commit | 414f139ae3f0a46de745c3b20b27e9632d71e839 (patch) | |
| tree | 50a0c2613738be6018471e48ccf654cee61378e0 /src/audio/audio_fsm.cpp | |
| parent | ae72566c0ec05c6a03d7e5746d2c5f99259e6297 (diff) | |
| download | tangara-fw-414f139ae3f0a46de745c3b20b27e9632d71e839.tar.gz | |
Audio fsm usability tweaks
- persist the current volume when the screen locks
- pause playback if headphones are removed
Diffstat (limited to 'src/audio/audio_fsm.cpp')
| -rw-r--r-- | src/audio/audio_fsm.cpp | 18 |
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; |
