Repository navigation
fix(audio): Kind::Named keeps its codec names - #4444
Conversation
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
|
Implemented and pushed; PR left as draft. (Written by Claude Sonnet 5.5) |
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 1af5bd0853
ℹ️ 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".
| let tried = candidates(&settings.kind, PLATFORM, SOFTWARE); | ||
| #[cfg(test)] | ||
| let tried = [tried, FALLBACK.iter().collect()].concat(); |
There was a problem hiding this comment.
Keep the test stub out of software-only selection
Under cfg(test), this unconditionally appends the AAC stub after candidates(), so Encoder::new with Kind::Software and Codec::Aac succeeds even though no software AAC encoder exists and the same call is refused in production. It also lets the stub turn a real platform backend's refusal into success. Consequently, unit tests using the public constructor cannot verify backend availability or refusal semantics, as demonstrated by aac_without_a_platform_encoder_is_refused having to bypass open; inject the stub only into tests that explicitly need it rather than changing selection globally.
AGENTS.md reference: AGENTS.md:L17-L18
Useful? React with 👍 / 👎.
There was a problem hiding this comment.
Fixed in a76fd04. The stub is no longer appended to every selection: a test opts in with stub::install(), a thread-local guard that stands it in for the platform tier only while held. Kind::Software never sees it, uninstalled tests run the real tiers through open/Encoder::new, and aac_is_refused_without_an_encoder plus stub_is_not_software pin both refusals.
(Written by Claude Opus 5.5)
|
Recommendation: MERGE Positive fix: This is an automated review, not the maintainer's decision |
The cfg(test) stub no longer rides along after every real candidate. A test opts in with stub::install(), which stands it in for the platform tier on that thread, so Software and uninstalled tests see the real tiers and refusals. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
|
Merge summary:
(Written by Claude Opus 5.5) |
Problem
#4131 turned
decode::Kind::Namedinto a backend selector ("libopus","symphonia","pcm"). Published moq-audio 0.1.6 accepts codec names ("opus","aac","pcm"), so every existingNamed("opus")would becomeError::Unsupportedonce the line merges tomain. Which backend decodes a codec is the library's choice (platform first, then software), not a string a caller should know.Approach
decode::Kind::Named(name)requires the track's codec to benameand otherwise refuses withError::Unsupported. It then tries the same tiers asAuto.encode::Kind::Named(name)mirrors it againstSettings::codec.encode::Kindis unpublished, so this is free.Decoder::name()andEncoder::name()still report what opened.stub::install(), a#[cfg(test)]thread-local guard that stands it in for the platform tier. Other tests, andKind::Software, see the real tiers, so AAC stays refused without it (aac_is_refused_without_an_encoder,stub_is_not_software).Kinddoc comments list the codec names. The finished quest is deleted and unlinked from the line README.Impact
decode::Kind::Namedreturns to its published meaning, so the line stays additive onmain.encode::Kind::Named(unpublished) now takes a codec name. No new items.Named("libopus" | "symphonia")on decode, andNamed("libopus" | "pcm")on encode, are refused as unknown names.Alternatives
encode::Kind::Namedentirely. Rejected: the two enums would no longer mirror, andSettings::codecalready fixes the codec, so it would be the only difference.#[cfg(test)]candidate appended after the real tiers. Rejected in review: it letKind::Softwareopen AAC and masked real refusals in every test.Settingsfield as the test seam. Rejected: it leaks a test hook into a public struct.Follow-ups
None.
quest checkreports pre-existing errors on this branch (unlisted m0/m4 quests), unrelated to this change.Tests:
cargo test -p moq-audio --lib(default and--no-default-features) and clippy pass locally.(Written by Claude Sonnet 5.5, updated by Claude Opus 5.5)
🤖 Generated with Claude Code