fix(BellEngine): remove hardcoded 0.5 s gap between melody loops (F-078, v2.5.1)
playbackLoop() slept 500 ms after every loop whenever the run had no end time (infinite, interval with total_duration 0, v1 continuous_loop with no total), so those modes paused between loops while timed / interval with a total did not. The delay was meant to give Player time to pause/stop, but play-once already stops synchronously in onMelodyLoopCompleted(), stop is checked before every pass and pause after every loop. Every looping mode now plays loop-to-loop with no gap; single is unaffected. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -90,6 +90,7 @@ Check `git log -- src/Version.hpp` for the real bump history before tagging a ne
|
||||
| F-075 | Play/stop command replies no longer wait for telemetry SD writes (deferred to TelemetryTask) | v2.4.1 | Stable |
|
||||
| F-076 | Fix: a `pause_duration` shorter than one melody loop no longer gets skipped | v2.4.2 | Stable |
|
||||
| F-077 | `mode: "infinite"` accepts optional `duration` + `pause_duration` for play/pause cycles forever | v2.5.0 | Stable |
|
||||
| F-078 | Fix: no more hardcoded ~0.5 s gap between loops in `infinite` and `interval` with `total_duration: 0` | v2.5.1 | Stable |
|
||||
|
||||
---
|
||||
|
||||
@@ -348,7 +349,7 @@ V2 play commands replace the ambiguous `continuous_loop` / `segment_duration` /
|
||||
| `"interval"` | Loop for `duration` ms, pause for `pause_duration` ms, repeat until `total_duration` ms elapsed | `duration`, `pause_duration`, `total_duration` |
|
||||
| `"infinite"` | Loop forever until a `stop` command; optionally in `duration`/`pause_duration` segments (F-077) | none, or `duration` + `pause_duration` |
|
||||
|
||||
Exact per-mode timing (500 ms tick, loops never cut short, pause/status transitions, the ~0.5 s gap between loops):
|
||||
Exact per-mode timing (500 ms tick, loops never cut short, pause/status transitions, no gap between loops):
|
||||
see `docs/reference/api-reference.md` → `playback.play` → Modes.
|
||||
|
||||
V1 timing fields (`segment_duration`, `continuous_loop`, `total_duration`) are still parsed when `mode` is absent, so the fix from F-024 continues to apply to V1 clients.
|
||||
@@ -1599,10 +1600,27 @@ Subsystem: `src/Player/Player.cpp`
|
||||
|
||||
| Sent | Behaviour |
|
||||
|---|---|
|
||||
| neither (or both `0`) | Unchanged: back-to-back loops (with the ~0.5 s engine gap) until `playback.stop`. |
|
||||
| neither (or both `0`) | Unchanged: back-to-back loops until `playback.stop` (no gap since F-078). |
|
||||
| both > 0 | Play `duration` ms, pause `pause_duration` ms, repeat until `playback.stop`. Same internal state as `interval` with `total_duration: 0`. |
|
||||
| only one > 0 | Rejected: `Invalid infinite segments: duration and pause_duration must both be > 0, or both omitted`. A duration with no pause would pause and resume on the same tick, and a pause with no duration never triggers. |
|
||||
|
||||
`total_duration` is never read for `infinite`. `interval` with `total_duration: 0` still works as before.
|
||||
|
||||
Subsystem: `src/Player/Player.cpp` (`validatePlayParams`, `setMelodyAttributes`)
|
||||
|
||||
### F-078 — No gap between melody loops
|
||||
|
||||
**Symptom.** Whenever a run had no end time (`total_duration` 0: `infinite`, `interval` with `total_duration: 0`,
|
||||
v1 `continuous_loop` with no total), the bells went quiet for ~0.5 s after each loop. `timed` and `interval`
|
||||
with a total looped with no gap, so the same melody sounded different depending on the mode.
|
||||
|
||||
**Cause.** `BellEngine::playbackLoop()` ran `vTaskDelay(500)` after `onMelodyLoopCompleted()` whenever
|
||||
`total_duration == 0` (or `continuous_loop` with no segments), to "give Player time to pause/stop".
|
||||
|
||||
**Fix.** The delay is removed. It wasn't needed: play-once (`single`) stops synchronously inside
|
||||
`onMelodyLoopCompleted()` (`isPlaying = false` before the engine continues), stop clears `isPlaying`, which
|
||||
`playbackLoop()` checks before every pass, and pause is checked in `engineLoop()` after every loop. Every looping
|
||||
mode now starts the next loop right after the previous one; the last step's `speed` beat is the only spacing.
|
||||
`single` is unaffected. Configurable inter-loop pauses are planned as a later setting.
|
||||
|
||||
Subsystem: `src/BellEngine/BellEngine.cpp`
|
||||
|
||||
Reference in New Issue
Block a user