Skip to content

fix(player): stabilize multi-audio switching#677

Closed
stackia wants to merge 5 commits into
mainfrom
codex/fix-ts-timestamp-continuity
Closed

fix(player): stabilize multi-audio switching#677
stackia wants to merge 5 commits into
mainfrom
codex/fix-ts-timestamp-continuity

Conversation

@stackia

@stackia stackia commented Jul 14, 2026

Copy link
Copy Markdown
Owner

Summary

  • Reuse the PCM audio player, AudioContext, and fixed output graph across same-slot stream reloads while fully resetting stream-specific state.
  • Make WSOLA initialization generation-safe so stale async work cannot attach to a new stream.
  • Stabilize internal and alternate audio switching across AAC, MP2, and unsupported AC-3/E-AC-3 tracks.
  • Keep unsupported tracks selected, show the existing audio warning, and preserve video playback with silent AAC timeline occupancy.
  • Reset PCM timing and startup synchronization consistently when returning from unsupported or MSE-decoded audio.

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:tsc
  • pnpm exec vite build web-ui
  • Release C build
  • uv run ruff check e2e
  • uv run pytest e2e --collect-only -q (539 tests)
  • ./scripts/run-e2e.sh --co (539 tests)
  • Chromium dev lab: HTTP TS internal, HLS-TS internal, and HLS-TS alternate audio switching across AAC, MP2, and AC-3
  • Volume, mute, pause/resume, startup sync, and repeated same-slot switching

@stackia stackia marked this pull request as ready for review July 14, 2026 18:58
@github-actions

github-actions Bot commented Jul 14, 2026

Copy link
Copy Markdown
Contributor

Documentation preview

The documentation preview has been deployed for this pull request.

@chatgpt-codex-connector chatgpt-codex-connector Bot 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.

💡 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".

Comment on lines +464 to +466
const start = firstDts - this._dtsBase;
const end = lastDts - this._dtsBase + frameDuration;
this._generateSilentAudio([

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge 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 👍 / 👎.

@stackia stackia closed this Jul 15, 2026
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.

1 participant