Repository navigation
Send volume and buffer fields as whole numbers - #192
Merged
Merged
Conversation
There was a problem hiding this comment.
🟢 Approval recommended
Static review found no blocking issues in these localized changes, and regression tests cover the principal behaviors, though they were not executed.
No open issues 🎉
What changed in this PR
This PR normalizes outgoing volume and buffer values to whole numbers, aligning the SDK’s messages with the Sendspin protocol’s integer fields.
Changes:
- Rounds buffer capacity and timing values, and rounds and clamps volume to 0–100.
- Rejects
NaNin public volume setters and commands, while retaining stored volume when hardware reportsNaN. - Adds regression tests and documents the new
RangeErrorbehavior.
| File | Description |
|---|---|
| tests/unit/state-manager.test.ts | Tests stored-volume rounding. |
| tests/unit/protocol-handler.test.ts | Tests buffer, hardware-volume, and controller-volume normalization. |
| tests/unit/core.test.ts | Tests rejection of NaN volume values. |
| src/index.ts | Documents volume-related RangeError behavior. |
| src/core/state-manager.ts | Centralizes volume rounding and clamping. |
| src/core/protocol-handler.ts | Normalizes outgoing numeric fields and handles hardware NaN. |
| src/core/core.ts | Validates volume before updating state or forwarding commands. |
Review effort: Balanced
33 tasks done
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this implement/fix?
The client sent volume,
required_lead_time_ms,min_buffer_msandbuffer_capacityexactly as the app passed them, so a fractional value like23.4reached the server even though the spec defines these fields as integers.They're now rounded before sending, and volume is also clamped to 0-100.
setVolumeand thevolumecontroller command now throw aRangeErroronNaN, which previously reached the server asnull.Related issue or spec PR (if applicable):
Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocumentationmaintenancecidependencies