Skip to content

fix(audio): advertise the Opus output sample rate#2404

Draft
kixelated wants to merge 1 commit into
devfrom
codex/fix-opus-output-rate
Draft

fix(audio): advertise the Opus output sample rate#2404
kixelated wants to merge 1 commit into
devfrom
codex/fix-opus-output-rate

Conversation

@kixelated

Copy link
Copy Markdown
Collaborator

Fixes #2400.

Summary

  • Normalize capture to a supported Opus output rate before constructing the AudioContext, keeping capture, framing, AudioEncoder configuration, and the advertised catalog rate identical.
  • Validate AudioEncoder output metadata against the catalog before publishing chunks.
  • Normalize legacy non-native Opus catalogs in watchers and stop decode loops after a fatal decoder error.

The root cause was that the publisher advertised the original capture graph rate as an AudioDecoderConfig. Safari can realize 44100 Hz after a Bluetooth mute/unmute cycle, while its Opus decoder requires one of the native Opus output rates. The watcher support probe accepted 44100 but decoding closed the decoder, and the legacy loop continued calling decode on the closed instance.

Public API changes

  • Adds Util.Opus.normalizeSampleRate(sampleRate?), an additive helper that selects 8, 12, 16, 24, or 48 kHz.
  • No breaking API, catalog schema, container, or wire-format changes.
  • No Rust or documentation sync is needed because this is browser WebCodecs rate selection and compatibility handling.

Test plan

  • nix develop --command just js fix
  • nix develop --command just js ci
  • nix develop --command just js test
  • Regression tests cover 44100 to 48000 normalization, catalog advertisement, native Opus rates, AAC preservation, legacy catalog compatibility, and closed-decoder handling.
  • Safari Bluetooth mute/unmute hardware verification remains pending.

(Written by GPT-5)

Co-Authored-By: Codex <noreply@openai.com>

@sourcery-ai sourcery-ai 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.

Sorry @kixelated, you have reached your weekly rate limit of 500000 diff characters.

Please try again later or upgrade to continue using Sourcery

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