feat(Player): V2 playback command namespace + segment_duration fix + mode field
F-024 — V1 single-segment fix: when continuous_loop=false, total_duration is
now always overwritten with segment_duration regardless of what the client
sent. Sending total_duration:0 explicitly no longer bypasses the stop timer.
The play-once fallback in onMelodyLoopCompleted is tightened to only fire when
both segment_duration and total_duration are zero.
F-025 — V2 command namespace: PlaybackHandler now registers playback.play and
playback.stop instead of the old root-level playback command. LegacyAdapter
maps V1 { cmd:playback, action:play/stop } to the new V2 names so all deployed
clients keep working without changes.
F-026 — V2 mode field: setMelodyAttributes accepts a mode string (single /
timed / interval / infinite) with a duration field, replacing the ambiguous
continuous_loop + segment_duration + total_duration triplet. V1 timing fields
are still parsed when mode is absent.
Docs: feature-catalog.md entries F-024, F-025, F-026 added.
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -33,6 +33,9 @@ Every feature — user-facing or significant internal mechanism — is listed he
|
||||
| F-021 | RelayHandler v1/v2 dual-format compatibility | v2.0.3 | Stable |
|
||||
| F-022 | Player speed guard (zero-speed defaults to 300 ms) | v2.0.3 | Stable |
|
||||
| F-023 | Telemetry bell max load default raised to 500 | v2.0.3 | Stable |
|
||||
| F-024 | V1 playback segment_duration fix (single-segment mode) | v2.0.4 | Stable |
|
||||
| F-025 | V2 playback command namespace (`playback.play` / `playback.stop`) | v2.0.4 | Stable |
|
||||
| F-026 | V2 playback `mode` field (`single` / `timed` / `interval` / `infinite`) | v2.0.4 | Stable |
|
||||
|
||||
---
|
||||
|
||||
@@ -241,6 +244,52 @@ Subsystem: `src/Player/Player.cpp:setMelodyAttributes()`
|
||||
|
||||
---
|
||||
|
||||
### F-024 — V1 playback segment_duration fix (single-segment mode)
|
||||
|
||||
When `continuous_loop: false` and `segment_duration > 0`, the melody now plays for the full `segment_duration` milliseconds (completing the last loop in progress) before stopping. Previously, sending `total_duration: 0` explicitly caused the player to stop after the very first loop regardless of `segment_duration`.
|
||||
|
||||
**Root cause:** `setMelodyAttributes` only derived `total_duration` from `segment_duration` when `total_duration` was *absent* from the payload. An explicit `total_duration: 0` bypassed the derivation, leaving the stop timer at zero. `onMelodyLoopCompleted` then hit the "play-once" shortcut and stopped immediately.
|
||||
|
||||
**Fix:** When `continuous_loop` is false, `total_duration` is now always overwritten with `segment_duration` regardless of what the client sent — it is semantically meaningless in single-segment mode. The play-once fallback in `onMelodyLoopCompleted` is also tightened to only fire when *both* `segment_duration` and `total_duration` are zero (truly no duration configured).
|
||||
|
||||
Subsystem: `src/Player/Player.cpp:setMelodyAttributes()`, `Player.cpp:onMelodyLoopCompleted()`
|
||||
|
||||
---
|
||||
|
||||
### F-025 — V2 playback command namespace
|
||||
|
||||
V2 clients send `playback.play` and `playback.stop` as the `cmd` field (with `"v": 2`), consistent with all other V2 namespaced commands (`relay.set_durations`, `system.restart`, etc.).
|
||||
|
||||
`PlaybackHandler` now registers these two commands directly. The old root-level `"playback"` command no longer exists in V2.
|
||||
|
||||
**Legacy (V1) compatibility:** `LegacyAdapter` maps `{ cmd:"playback", action:"play" }` → `"playback.play"` and `{ cmd:"playback", action:"stop" }` → `"playback.stop"`. All deployed V1 clients continue to work without any changes.
|
||||
|
||||
Subsystem: `src/Communication/Handlers/PlaybackHandler/PlaybackHandler.cpp`, `src/Communication/CommandBus/LegacyAdapter.cpp`
|
||||
|
||||
---
|
||||
|
||||
### F-026 — V2 playback `mode` field
|
||||
|
||||
V2 play commands replace the ambiguous `continuous_loop` / `segment_duration` / `total_duration` triplet with a single `mode` string and a `duration` field:
|
||||
|
||||
| `mode` | Behaviour | Required fields |
|
||||
|---|---|---|
|
||||
| `"single"` | Play exactly one melody loop, then stop | none |
|
||||
| `"timed"` | Loop continuously for `duration` ms, stop at end of a full loop | `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 | none |
|
||||
|
||||
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.
|
||||
|
||||
**Example V2 play command:**
|
||||
```json
|
||||
{ "cmd": "playback.play", "v": 2, "contents": { "pid": "builtin_festive_4voices", "speed": 232, "mode": "timed", "duration": 30000, "note_assignments": [1,2,3,4,0,0,0,0,0,0,0,0,0,0,0,0], "url": "..." } }
|
||||
```
|
||||
|
||||
Subsystem: `src/Player/Player.cpp:setMelodyAttributes()`
|
||||
|
||||
---
|
||||
|
||||
### F-023 — Telemetry bell max load default raised to 500
|
||||
|
||||
`bellMaxLoad[i]` initialised to `500` (was `200`). This is the denominator used to calculate bell load percentage in telemetry reports. The old value caused false "overload" warnings on normal use patterns.
|
||||
|
||||
Reference in New Issue
Block a user