Skip to content

refactor: rename static_delay_ms to output_delay_ms - #164

Merged
maximmaxim345 merged 1 commit into
mainfrom
refactor/output-delay
Aug 20, 2026
Merged

maximmaxim345 merged 1 commit into
mainfrom
refactor/output-delay

Conversation

@chrisuthe

Copy link
Copy Markdown
Member

Fixes #154.

Renames the player role's static delay to output delay throughout roles/player/v1.md — field, command enum, supported_commands value, definition heading, and every prose reference (lead-time note, send-ahead formula, timestamp translation, both Playback Synchronization bullets). Verified no other source file refers to the field, as the issue states.

⚠️ Breaking: static_delay_ms → output_delay_ms (one client/state field, one server/command payload field) and set_static_delay → set_output_delay (command enum value + supported_commands entry). No alias. This affects every player client.

The clarifying phrase

Per the issue ("One clarifying phrase there prevents the new name from being read as covering those"), the definition now reads:

Output delay: The default is 0, meaning audio exits the device's audio port at the timestamp. output_delay_ms compensates for additional delay beyond the port (external speakers, amplifiers); it does not cover processing delays before the port (DAC latency, audio buffers), which the client compensates itself.

One small fix beyond the issue's letter

The timestamp-translation text listed amplifier delays among the processing delays clients compensate themselves — contradicting the definition, which places amplifiers beyond the port under output_delay_ms. With the boundary now stated explicitly in the definition, the example list drops "amplifier delays":

Clients should compensate for any known processing delays (e.g., DAC latency, audio buffer delays) by accounting for these delays when submitting audio to the hardware.

Happy to revert if amplifiers were intended on both sides.

Coordination

Per the issue: #142 (moves supported_commands) and #93 (out-of-range handling for this field) should use the new name if they land after this.

Verification

  • Zero static_delay / "static delay" occurrences remain in any source file.
  • python3 tools/build-readme.py --check passes.

Renames the player role's static delay to "output delay" throughout
roles/player/v1.md. The old name read as "unchangeable" to users,
who configure exactly this delay; "output delay" matches the familiar
TV/AVR term while describing the same thing - the latency of the
output chain past the audio port.

BREAKING CHANGE: wire identifiers change for player clients.

  static_delay_ms   -> output_delay_ms   (client/state field and
                                          server/command payload)
  set_static_delay  -> set_output_delay  (command enum value and
                                          supported_commands entry)

The definition gains one clarifying phrase so the new name is not
read as covering processing delays before the port (DAC latency,
buffers), which the client compensates itself. "Amplifier delays" is
dropped from the timestamp-translation example list of processing
delays: amplifiers are the canonical output_delay_ms case, and
listing them on both sides of the boundary contradicted the
definition.

Fixes #154

@maximmaxim345 maximmaxim345 left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks @chrisuthe !
The "One small fix beyond" also looks good.

@maximmaxim345
maximmaxim345 merged commit 485617f into main Aug 20, 2026
1 check passed
@maximmaxim345
maximmaxim345 deleted the refactor/output-delay branch August 20, 2026 19:35
chrisuthe added a commit to Sendspin/aiosendspin that referenced this pull request Sep 15, 2026
## Summary

Implements [spec PR #164](Sendspin/spec#164)
("rename static_delay_ms to output_delay_ms"), which aiosendspin hadn't
caught up to yet:

- `PlayerStatePayload.static_delay_ms` → `output_delay_ms`
- `PlayerCommandPayload.static_delay_ms` → `output_delay_ms`
- `PlayerCommand.SET_STATIC_DELAY` (`"set_static_delay"`) →
`SET_OUTPUT_DELAY` (`"set_output_delay"`)
- `StaticDelayChangedEvent` → `OutputDelayChangedEvent` (a public event
type this repo exposes, not wire-facing, but part of the same rename —
missed in the first commit, fixed in the second)

Applied consistently across the server-side player role, client-side
model usage, and docstrings.

**Backward compatibility** (mirroring
[#343](#343 "keep serving
clients on the pre-rename artwork wire"): a client still using
`static_delay_ms`/`set_static_delay` is tolerated, not disconnected.

- `PlayerCommand.SET_STATIC_DELAY` stays a valid enum value.
- `PlayerStatePayload.__pre_deserialize__` rewrites incoming
`static_delay_ms` onto `output_delay_ms`, recording `legacy_delay_key`
so `PlayerV1Role.client_state_deviations()` flags it — tolerated when
the server allows noncompliant clients, rejected in strict mode via the
existing `flag_noncompliance` machinery (no new enforcement path
needed).
- `set_output_delay()` now addresses the client using whichever spelling
it declared in `state_supported_commands` — a client that only ever
declared `set_static_delay` wouldn't recognize a `set_output_delay`
command in `server/command`.
- `PlayerCommandPayload.__post_serialize__` serializes `output_delay_ms`
under the wire key matching `command`, so constructing the payload with
`command=SET_STATIC_DELAY` produces the pre-rename wire shape from the
same Python-side field.

## Why now

Same root cause as #343:
[Sendspin/sendspin-jvm#33](Sendspin/sendspin-jvm#33)
adopted the new field names ahead of aiosendspin. Once #343 merged and
got a sendspin-jvm client's `client/hello` past the artwork-parsing
failure, `client/state` then failed for the same reason one layer deeper
— a sendspin-jvm client sends `output_delay_ms` and declares
`set_output_delay` in `supported_commands`, and aiosendspin rejected it:
`"'set_output_delay' is not a valid PlayerCommand"`. See
[Sendspin/conformance#107](Sendspin/conformance#107)
for where this surfaced (re-running the matrix after #343 merged).

## Test plan

- [x] Full test suite: `pytest -n0` (xdist disabled — its worker-spawn
native `av`/PyAV extension loading is flaky in this sandbox, independent
of this change) — 1606 passed, 8 skipped, 0 failed
- [x] `ruff check` and `ruff format --check` both clean

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
Co-authored-by: Chris Uthe <chris.uthe@openhomefoundation.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rename static_delay_ms to output_delay_ms (and set_static_delay to set_output_delay)

2 participants