From ced38fda0bb1aebd808ad8b4ec073f516e5478f6 Mon Sep 17 00:00:00 2001 From: bonamin Date: Wed, 28 Oct 2026 10:41:11 +0200 Subject: [PATCH] fix(Player): stop short pauses being skipped between segments (F-076, v2.4.2) timeToResume() measured the pause from segmentCmpltTime, which still held the previous loop's end while the engine finished the loop that was playing when the pause was flagged. A pause_duration shorter than one melody loop therefore resumed before the bells ever went quiet. Only start counting once that loop has ended (segmentCmpltTime >= pauseTime). Co-Authored-By: Claude Opus 5.5 --- docs/features/feature-catalog.md | 19 +++++++++++++++++++ src/Player/Player.cpp | 6 +++++- src/Version.hpp | 3 ++- 3 files changed, 26 insertions(+), 2 deletions(-) diff --git a/docs/features/feature-catalog.md b/docs/features/feature-catalog.md index b003c6a..978bc46 100644 --- a/docs/features/feature-catalog.md +++ b/docs/features/feature-catalog.md @@ -88,6 +88,7 @@ Check `git log -- src/Version.hpp` for the real bump history before tagging a ne | F-073 | Confirmed delivery for `status/playback` + `control/reports` (QoS 1, PUBACK tracked, reset + republish/resend); AsyncMqttClient vendored + patched; all dependencies pinned | v2.4.0 | Stable | | F-074 | Fix: `mode: "infinite"` no longer flips status playing/paused every ~0.5 s | v2.4.0 | Stable | | 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 | --- @@ -1566,3 +1567,21 @@ held while telemetry is paused for OTA and done right after `resume()`. Before t one write of the latest values. Subsystem: `src/Telemetry/Telemetry.hpp`, `src/Telemetry/Telemetry.cpp` + +### F-076 — Fix short pauses being skipped + +**Symptom.** Found while reviewing the pause logic for F-077 (2026-10-28): in a segmented play (`interval`, or +v1 `continuous_loop`), a `pause_duration` shorter than one melody loop could be skipped. Status went `paused` +then back to `playing`, but the bells never stopped between segments. + +**Cause.** `timeToPause()` flags the pause when the segment time runs out, which is usually in the middle of a +loop. The engine finishes that loop before it actually waits. `timeToResume()` measured the pause from +`segmentCmpltTime`, but until that loop ends `segmentCmpltTime` still holds the end of the *previous* loop. If +`previous loop end + pause_duration` was already in the past, the next 500 ms tick resumed before the loop +had finished, so there was no silence. + +**Fix.** `timeToResume()` only runs once `segmentCmpltTime >= pauseTime`, that is, once the loop that was +playing when the pause was flagged has ended. The silence now always lasts `pause_duration` (rounded up to the +500 ms timer tick), measured from the end of that loop. Pauses longer than one loop already worked this way. + +Subsystem: `src/Player/Player.cpp` diff --git a/src/Player/Player.cpp b/src/Player/Player.cpp index 9236255..9001e0c 100644 --- a/src/Player/Player.cpp +++ b/src/Player/Player.cpp @@ -804,7 +804,11 @@ bool Player::timeToPause(unsigned long now) { // Check if it's time to resume playback bool Player::timeToResume(unsigned long now) { - if (isPaused) { + // The pause is flagged mid-loop and the engine finishes that loop first, so + // until it does, segmentCmpltTime still holds the PREVIOUS loop's end. A + // pause_duration shorter than one loop would then resume before the bells + // ever went quiet — wait for the loop that was playing at pause time to end. + if (isPaused && segmentCmpltTime >= pauseTime) { uint64_t timeToResume = segmentCmpltTime + (uint64_t)pause_duration; if ((uint64_t)now >= timeToResume) { _pendingResumeReason = "Pause duration reached — resuming"; diff --git a/src/Version.hpp b/src/Version.hpp index f0ddeba..7f514e3 100644 --- a/src/Version.hpp +++ b/src/Version.hpp @@ -29,8 +29,9 @@ // WiFi modem sleep off, vendored/patched AsyncMqttClient, pinned deps, // WiFi/NTP task-retry, infinite-mode status flicker fix (F-071..F-074) // v2.4.1 - Play/stop replies no longer wait for telemetry SD writes (F-075) +// v2.4.2 - Fixes pauses shorter than one melody loop being skipped (F-076) // ═══════════════════════════════════════════════════════════════════════ -#define FW_VERSION "2.4.1" +#define FW_VERSION "2.4.2" // ═══════════════════════════════════════════════════════════════════════ // SemVer — lightweight 3-part version struct