From 938ba62f57ed2c002bae4aec236eeaeb200e4cba Mon Sep 17 00:00:00 2001 From: jacqueline Date: Thu, 4 Jan 2024 15:57:58 +1100 Subject: refactor handling of volume steps; improve controls --- src/audio/audio_fsm.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'src/audio/audio_fsm.cpp') diff --git a/src/audio/audio_fsm.cpp b/src/audio/audio_fsm.cpp index 90bfd60b..a5179156 100644 --- a/src/audio/audio_fsm.cpp +++ b/src/audio/audio_fsm.cpp @@ -129,7 +129,7 @@ void Uninitialised::react(const system_fsm::BootComplete& ev) { auto& nvs = sServices->nvs(); sI2SOutput->SetMaxVolume(nvs.AmpMaxVolume()); - sI2SOutput->SetVolumeDb(nvs.AmpCurrentVolume()); + sI2SOutput->SetVolume(nvs.AmpCurrentVolume()); if (sServices->nvs().OutputMode() == drivers::NvsStorage::Output::kHeadphones) { @@ -188,6 +188,10 @@ void Playback::exit() { vTaskDelay(pdMS_TO_TICKS(10)); sOutput->SetMode(IAudioOutput::Modes::kOnPaused); + // Stash the current volume now, in case it changed during playback, since we + // might be powering off soon. + sServices->nvs().AmpCurrentVolume(sOutput->GetVolume()); + events::System().Dispatch(PlaybackFinished{}); events::Ui().Dispatch(PlaybackFinished{}); } -- cgit v1.2.3