Skip to content

Always advertise FLAC or PCM to the server - #179

Open
marcelveldt wants to merge 2 commits into
mainfrom
marcelveldt/codec-rules-spec-238
Open

marcelveldt wants to merge 2 commits into
mainfrom
marcelveldt/codec-rules-spec-238

Conversation

@marcelveldt

@marcelveldt marcelveldt commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Sendspin/spec#238 makes Opus optional for servers. Every server must support FLAC and PCM and may support Opus, so every player must list FLAC or PCM in its supported_formats; a player is not told which codecs the server can produce. An app configured with codecs: ["opus"] sent a hello that a server without Opus could not serve at all.

  • The advertised format list now always carries FLAC or PCM. When neither is requested, or neither survives the browser filter, FLAC and PCM are appended as lowest-priority fallbacks (FLAC first, each only where the browser decodes it) and a console warning says so. The "no supported codecs" error and the up-front codec check that relied on it are gone, since the list can no longer be empty.
  • server/hello is typed per the spec, including the new source@v1_support object a server sends when it accepts source clients. This SDK implements no source role, so the field is informational only.
  • The decoder needs no change: it follows the codec the server picks in stream/start, and the FLAC and PCM paths never touch the Opus decoders.
  • Tests cover the FLAC/PCM guarantee, the buffer capacity that follows from the fallback, and a server/hello carrying source@v1_support.

Sendspin/spec#238 makes Opus optional for servers: they must support
flac and pcm and may support opus, and players must always list flac or
pcm in supported_formats since they are not told what a server can
produce. An opus-only codec configuration produced a hello that a server
without Opus could not serve at all.

The format list now appends pcm as the lowest-priority fallback when
neither flac nor pcm is offered, which also retires the "no supported
codecs" error since the list can no longer be empty. The server/hello
type gains the new source@v1_support object, informational only as this
SDK implements no source role.
@marcelveldt marcelveldt added the maintenance This PR does maintenance on the Code label Sep 15, 2026
@marcelveldt
marcelveldt requested a lite review from Copilot September 15, 2026 22:10

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.

🟢 Approval recommended

The reviewed changes are covered by tests with no blocking issues identified.

Pull request overview

Updates codec negotiation to always advertise FLAC or PCM and adds typed server/hello support data.

Changes:

  • Adds PCM fallback and related capacity tests.
  • Removes obsolete codec validation.
  • Adds source@v1_support typing and coverage.
File summaries
File Summary
tests/unit/protocol-handler.test.ts Tests codec advertising and server hello handling.
tests/unit/codec-support.test.ts Tests fallback formats and buffer capacity.
src/types.ts Adds typed server hello fields.
src/core/core.ts Removes obsolete codec validation.
src/core/codec-support.ts Ensures FLAC or PCM is advertised.
Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

When neither flac nor pcm is requested or survives the browser filter,
append both where the browser decodes them, flac first, so an opus-only
configuration gets the lower-bandwidth lossless format on a server
without Opus instead of raw PCM.

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.

🟢 Approval recommended

No unresolved blocking issues were identified.

Review details
  • Files reviewed: 5/5 changed files
  • Comments generated: 0 new
  • Review effort level: Lite

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintenance This PR does maintenance on the Code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants