diff options
| author | jacqueline <me@jacqueline.id.au> | 2024-05-09 10:59:49 +1000 |
|---|---|---|
| committer | jacqueline <me@jacqueline.id.au> | 2024-05-09 10:59:49 +1000 |
| commit | 690c64c151777121afc2b39868f73b0fe666458e (patch) | |
| tree | 03be2c6fbc1496e48d465f2ec3510d11ab4d73d9 /src/tangara/audio/audio_fsm.cpp | |
| parent | 265049c5192cf0ce862c7db7b4745636afb6c17b (diff) | |
| download | tangara-fw-690c64c151777121afc2b39868f73b0fe666458e.tar.gz | |
Fix playback after restoring queue on boot
Diffstat (limited to 'src/tangara/audio/audio_fsm.cpp')
| -rw-r--r-- | src/tangara/audio/audio_fsm.cpp | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/src/tangara/audio/audio_fsm.cpp b/src/tangara/audio/audio_fsm.cpp index a7c006f5..71f41938 100644 --- a/src/tangara/audio/audio_fsm.cpp +++ b/src/tangara/audio/audio_fsm.cpp @@ -191,6 +191,11 @@ void AudioState::react(const internal::StreamStarted& ev) { if (!sIsPaused && !is_in_state<states::Playback>()) { transit<states::Playback>(); + } else { + // Make sure everyone knows we've got a track ready to go, even if we're + // not playing it yet. This mostly matters when restoring the queue from + // disk after booting. + emitPlaybackUpdate(true); } } @@ -485,12 +490,13 @@ void Playback::react(const system_fsm::SdStateChanged& ev) { void Playback::react(const internal::StreamHeartbeat& ev) { sStreamCues.update(sOutput->samplesUsed()); - auto current = sStreamCues.current(); - if (!current.first) { - transit<Standby>(); - } else { + if (sStreamCues.hasStream()) { emitPlaybackUpdate(false); + } else { + // Finished the current stream, and there's nothing upcoming. We must be + // finished. + transit<Standby>(); } } |
