Repository navigation
Fix playback timing after delay changes, clears and reconnects - #209
Merged
Merged
Conversation
There was a problem hiding this comment.
🟡 Changes recommended
Increasing the delay from 0 to 10 ms in quality-local can leave buffered playback at the old delay because an overlapping chunk is shifted forward, propagating an uncorrected 10 ms timing error.
1 open issue
What changed in this PR
This PR improves playback timing and stream lifecycle handling in the Sendspin SDK, addressing late chunks, output-delay changes, pending decodes, and reconnects.
Changes:
- Drops chunks whose adjusted start time has passed and enables delay-change cutovers in every correction mode.
- Invalidates pending audio on stream resets and ends stale streams when a new connection activates.
- Removes
CorrectionThresholds.immediateDelayCutoverand documentsquality-localas non-compliant with the specification.
| File | Description |
|---|---|
| tests/unit/scheduler.test.ts | Adds late-chunk and delay-change regression tests. |
| tests/unit/protocol-handler.test.ts | Tests reconnect cleanup and stream preservation during re-handshakes. |
| tests/unit/core.test.ts | Tests dropping pending decodes after a stream clear. |
| src/types.ts | Removes the cutover option and clarifies correction-mode documentation. |
| src/core/protocol-handler.ts | Ends stale player streams on new-connection activation. |
| src/core/core.ts | Invalidates pending decodes when resetting streams. |
| src/audio/scheduler.ts | Updates late-chunk dropping and delay-change cutovers. |
| README.md | Documents the quality-local compliance limitation. |
| index.html | Adds the compliance warning to sample-player help text. |
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?
Fixes several cases where audio played at the wrong time or mixed in audio it should have dropped:
qualityandquality-localcorrection modes, a changed output delay never applied to a running stream. Every mode now resyncs once when the delay changes.SendspinCoreused on its own, audio still decoding when a stream was cleared or ended was emitted afterwards.stream/starton the new connection was treated as a format update of the old stream, so old and new audio got mixed. Buffered audio from the old connection now stops when the new connection is activated.quality-localis now documented as not spec compliant, since it leaves large sync errors uncorrected.This is a breaking change:
CorrectionThresholds.immediateDelayCutoveris removed, since every mode now applies delay changes right away.Related issue or spec PR (if applicable):
Types of changes
bugfixnew-featureenhancementbreaking-changerefactordocumentationmaintenancecidependencies