Skip to content

Reduce playback gaps after disconnects - #84

Merged
maximmaxim345 merged 6 commits into
mainfrom
fix/defer-playback-reset-on-disconnect
Apr 13, 2026
Merged

maximmaxim345 merged 6 commits into
mainfrom
fix/defer-playback-reset-on-disconnect

Conversation

@maximmaxim345

Copy link
Copy Markdown
Member

Keep locally buffered audio running WebSocket connection drops instead of clearing playback immediately:

  • SendspinPlayer now defers the hard reset until the buffered runway is exhausted
  • AudioProcessor keeps small scheduling horizons from already-decoded audio so queued data continues to play while reconnecting

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Pull request overview

This PR aims to reduce audible playback gaps during transient WebSocket disconnects by allowing already-buffered/decoded audio to continue playing before performing a hard playback reset.

Changes:

  • Defer SendspinPlayer’s disconnect reset until the locally buffered playback runway is exhausted (with a small grace window).
  • Add AudioProcessor.measureBufferedPlaybackRunwaySec() to quantify remaining scheduled + queued audio.
  • Introduce a refill timer in AudioProcessor to keep scheduling from already-decoded queued audio without relying on new network packets.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/index.ts Schedules a delayed playback reset on socket close based on buffered runway, and cancels it on reconnect/intentional disconnect.
src/audio-processor.ts Adds buffered-runway measurement and a refill timer to keep scheduling queued decoded audio ahead.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread src/index.ts Resolved
Comment thread src/audio-processor.ts Resolved
@maximmaxim345
maximmaxim345 merged commit c9388a6 into main Apr 13, 2026
2 checks passed
@maximmaxim345
maximmaxim345 deleted the fix/defer-playback-reset-on-disconnect branch April 13, 2026 11:13
balloob pushed a commit that referenced this pull request Apr 13, 2026
Port two upstream bug fixes into the modular Core/Scheduler architecture:

- #83 Reduce scheduling horizon on Cast: Add CAST_SCHEDULE_HORIZON_*
  constants and isCastRuntime parameter to AudioScheduler. Cast
  receivers now use shorter horizons (1.5s/1s/0.5s) to reduce
  stuttering.

- #84 Reduce playback gaps after disconnects: Add
  measureBufferedPlaybackRunwaySec() and refill scheduling to
  AudioScheduler. SendspinPlayer defers playback reset on disconnect
  until buffered audio is exhausted, using new onConnectionOpen/
  onConnectionClose events from Core.

https://claude.ai/code/session_018UYYEXUZVuQ2Z4Texa7W6m
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bugfix Fixes a bug

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants