fix(player): stabilize multi-audio switching#677
Conversation
Documentation previewThe documentation preview has been deployed for this pull request. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: abc1b0a6d4
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const start = firstDts - this._dtsBase; | ||
| const end = lastDts - this._dtsBase + frameDuration; | ||
| this._generateSilentAudio([ |
There was a problem hiding this comment.
Handle timestamp restarts in silent audio-only tracks
When the selected track is an audio-only TS pipeline using silent AAC occupancy (for example an alternate AC-3/E-AC-3 rendition on a browser where that codec is unsupported), these raw firstDts - _dtsBase values are passed to _generateSilentAudio, which keeps _silentAudioLastDts as a monotonic output cursor. If the audio rendition crosses a TS timestamp restart and end moves behind the previous cursor, _generateSilentAudio emits no samples until the source timestamps catch up, leaving the audio SourceBuffer without the promised silent occupancy and risking a stall instead of continuing silent video playback.
Useful? React with 👍 / 👎.
Summary
Root cause
Audio switches mixed stream-level state with long-lived Web Audio resources. Stale PCM scheduling and WSOLA initialization could survive a reset, while unsupported AC-3 caused the MSE audio transition to fail and roll the worker back to the previous track. Subsequent switches then inherited inconsistent timing and decoder state, resulting in silence or intermittent audio.
User impact
Same-slot channel changes now reuse the existing Web Audio runtime without leaking audio from the previous stream. AAC and MP2 switches recover reliably. Selecting unsupported AC-3/E-AC-3 remains on that track, displays a warning, and continues silent video playback until the user selects a supported track.
Validation
pnpm exec biome check ...pnpm run type-check:tscpnpm exec vite build web-uiuv run ruff check e2euv run pytest e2e --collect-only -q(539 tests)./scripts/run-e2e.sh --co(539 tests)