fix(Player): stop playing/paused status flicker in mode "infinite" (F-074)

"infinite" maps to continuous_loop=true with segment_duration=0, and
timeToPause() only checked continuous_loop, so every duration-timer tick
paused and the next resumed: ~2 status broadcasts per second on WebSocket
and retained MQTT status/playback for the whole melody. Zero segment length
now means "no segments". Found and verified on hardware.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-15 22:11:05 +03:00
co-authored by Claude Opus 5.5
parent 009cefcb90
commit 9d69733257
2 changed files with 22 additions and 1 deletions
+17
View File
@@ -86,6 +86,7 @@ Check `git log -- src/Version.hpp` for the real bump history before tagging a ne
| F-071 | MQTT self-recovery — single supervisor task replaces timer/task chain, wedge detection (stuck connect, missing heartbeat PUBACK), LWT payload fix, `mqtt.status` diagnostics | v2.3.0 | Stable |
| F-072 | Lower status/reply latency — QoS 0 for non-critical MQTT topics; WiFi modem sleep disabled | v2.3.0 | Stable |
| F-073 | Confirmed delivery for `status/playback` + `control/reports` (QoS 1, PUBACK tracked, reset + republish/resend); AsyncMqttClient vendored + patched; all dependencies pinned | v2.3.0 | Stable |
| F-074 | Fix: `mode: "infinite"` no longer flips status playing/paused every ~0.5 s | v2.3.0 | Stable |
---
@@ -1532,3 +1533,19 @@ both ends, AsyncMqttClient drops unacked packets on reconnect. Before this chang
Subsystem: `lib/AsyncMqttClient/`, `platformio.ini`, `src/Communication/Drivers/MQTTDriver/`,
`src/Communication/CommunicationRouter/CommunicationRouter.cpp`, `src/Networking/Networking.cpp`, `src/main.cpp`
### F-074 — Fix status flicker in `mode: "infinite"`
**Symptom.** Found while measuring latency on hardware (2026-10-15): during a `playback.play` with
`mode: "infinite"`, the device broadcast `paused` → `playing` → `paused` … about twice a second for the whole
melody, on WebSocket and as retained MQTT `status/playback` messages. The bells kept ringing.
**Cause.** `"infinite"` maps to `continuous_loop=true, segment_duration=0`. `Player::timeToPause()` only
checked `continuous_loop`, so with a 0 ms segment every duration-timer tick paused, and since
`pause_duration` was also 0, the next tick resumed. The same happened for a v1 request with
`continuous_loop: true` and no `segment_duration`.
**Fix.** `timeToPause()` also requires `segment_duration > 0`: zero means "no segments". `"interval"` already
rejects `duration: 0`, so no valid segmented mode is affected.
Subsystem: `src/Player/Player.cpp`
+5 -1
View File
@@ -787,7 +787,11 @@ void Player::onMelodyLoopCompleted() {
// Check if it's time to pause playback
bool Player::timeToPause(unsigned long now) {
if (isPlaying && continuous_loop) {
// segment_duration == 0 means "no segments" (mode "infinite", or v1
// continuous_loop with no segment length). Without this guard every timer
// tick paused and the next resumed, so status flipped playing/paused about
// twice a second for the whole melody, on WebSocket and MQTT (F-074).
if (isPlaying && continuous_loop && segment_duration > 0) {
uint64_t timeToPause = segmentStartTime + (uint64_t)segment_duration;
if ((uint64_t)now >= timeToPause && !isPaused) {
_pendingPauseReason = "Segment duration reached — pausing";