diff options
| author | jacqueline <me@jacqueline.id.au> | 2023-10-16 13:52:43 +1100 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2023-10-16 13:52:43 +1100 |
| commit | 7523772886ca37cf05d0ad5b24f6d520e314242e (patch) | |
| tree | ab298342307c1023ef4e1a2a004407ca072dfc25 /src/audio/audio_fsm.cpp | |
| parent | 96ea6cef8881d005cb06be8a9132535a5564d5fd (diff) | |
| download | tangara-fw-7523772886ca37cf05d0ad5b24f6d520e314242e.tar.gz | |
Decouple play/pause from output on/off
I think this was the cause of toggling play/pause making audio go away.
Or at least I can't repro that bug anymore, anyway.
Diffstat (limited to 'src/audio/audio_fsm.cpp')
| -rw-r--r-- | src/audio/audio_fsm.cpp | 7 |
1 files changed, 5 insertions, 2 deletions
diff --git a/src/audio/audio_fsm.cpp b/src/audio/audio_fsm.cpp index e470300f..5020a6ef 100644 --- a/src/audio/audio_fsm.cpp +++ b/src/audio/audio_fsm.cpp @@ -81,6 +81,7 @@ void AudioState::react(const OutputModeChanged& ev) { // TODO: handle SetInUse ESP_LOGI(kTag, "output mode changed"); auto new_mode = sServices->nvs().OutputMode(); + sOutput->SetMode(IAudioOutput::Modes::kOff); switch (new_mode) { case drivers::NvsStorage::Output::kBluetooth: sOutput = sBtOutput; @@ -89,6 +90,7 @@ void AudioState::react(const OutputModeChanged& ev) { sOutput = sI2SOutput; break; } + sOutput->SetMode(IAudioOutput::Modes::kOnPaused); } namespace states { @@ -125,6 +127,7 @@ void Uninitialised::react(const system_fsm::BootComplete& ev) { } else { sOutput = sBtOutput; } + sOutput->SetMode(IAudioOutput::Modes::kOnPaused); sSampleConverter.reset(new SampleConverter()); sSampleConverter->SetOutput(sOutput); @@ -170,7 +173,7 @@ void Standby::react(const TogglePlayPause& ev) { void Playback::entry() { ESP_LOGI(kTag, "beginning playback"); - sOutput->SetInUse(true); + sOutput->SetMode(IAudioOutput::Modes::kOnPlaying); events::System().Dispatch(PlaybackStarted{}); events::Ui().Dispatch(PlaybackStarted{}); @@ -181,7 +184,7 @@ void Playback::exit() { // TODO(jacqueline): Second case where it's useful to wait for the i2s buffer // to drain. vTaskDelay(pdMS_TO_TICKS(10)); - sOutput->SetInUse(false); + sOutput->SetMode(IAudioOutput::Modes::kOnPaused); events::System().Dispatch(PlaybackFinished{}); events::Ui().Dispatch(PlaybackFinished{}); |
