You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
feat(playback): start on an audio track the client plays without conversion - #3115
Related issue: N/A
Validation tasks: no passed case is reached; touches #197 (Playback) and #1249 CORE3, neither run yet
When a client starts playback without naming an audio track, the server picks one by the profile's language and the file's default flag, without looking at what the client can play. For a file whose default is TrueHD 7.1 Atmos beside an English E-AC-3 or AC-3 5.1 track, a Roku (no TrueHD, no multichannel AAC) gets the TrueHD track converted to stereo AAC, while the 5.1 track it could play as it is goes unused. Other clients that cannot take the default have the same problem.
With this change, a v3 start that names no track still resolves the profile's preference first. If the plan for that track converts its audio (or does not plan), and the plan for another main track in the same language plays it unconverted with at least as many channels, the server starts on that track. A track the viewer saved for the series still plays as saved. A client that plays TrueHD keeps it.
Approach
playback.PreferUnconvertedAudioTrackV3 holds the rule. It takes an outcome function that plans the file with one track and reports whether the route plays, converts the audio, and how many channels reach the client. The planner is the authority, so container support, device quirks, and video routes that re-encode every track all count.
preferredAudioTrackIndexV3 now also reports whether the saved series track decided (playback.SavedAudioTrackChosen). When it did not, the start handler calls playableStartAudioV3 after loading planner settings, which plans the requested file once for the chosen track and, only if that converts, once per same-language candidate. Each plan goes through the escalation the start applies to a progressive remux with no route (escalateRefusedProgressiveRemuxV3). When a buffered Auto start then moves to a lower version (lowerBufferedVersion), the preference is refined again on that version rather than carried over by position.
Commentary and audio-description tracks are never substituted in. Among several candidates the most channels win, then Atmos, then codec rank (lossless, DTS, E-AC-3, AC-3, AAC), then track order.
effective_audio_track_index in catalog reads is unchanged and still knows no device. The protocol doc now says a client omits the track when the viewer has not picked one, rather than echoing that index; the plan's selected_tracks names what plays.
Apple and Android currently send the effective index back as an explicit track, so they keep today's behavior until they omit it. Follow-ups for both are drafted. jellycompat already has its own fallback from TrueHD to a same-language E-AC-3 or AC-3 track and is unchanged.
Validation
Unit tests: the selection rule with stubbed outcomes, and planner-backed cases, including one where the other track would be downmixed to stereo and must not be chosen. Handler tests: TestPlayableStartAudioV3JudgesTheEscalatedRoute (a candidate that only looks copied before escalation) and TestBufferedAutoRefinesAudioOnTheLowerVersion (a lower version whose matching track by position is stereo).
Isolated sandbox with release fixtures, Roku-shaped start requests: FX-019 and FX-038 (TrueHD 7.1 default, AC-3 5.1) start on AC-3 5.1, copied, where they converted TrueHD to stereo AAC. FX-011 (DTS-HD MA default, only a commentary alternative) keeps DTS-HD.
Roku Ultra on the same sandbox: the main Roku build (which names the effective track) plays TrueHD as stereo AAC; the Roku build that omits the track plays AC-3 5.1.
go build, gofmt, go vet, make lint-changed, make test-go (two jellycompat DV-strip tests fail locally on main too and pass in CI), and the playback-fixture, API v2, route-inventory, and other generated-contract checks.
A start that names no track now plans the requested file once more before the real planning, and once per same-language candidate when the preferred track converts. Planning is in memory; the Dolby Vision RPU probe it can trigger is cached across requests.
When the requested file cannot play at all and the server falls back to another stored version, the track is carried there by MatchAudioTrackAcrossVersions, as an explicit pick would be. The refinement changes nothing in that case, since no track on the requested file plans.
Checklist
I read and can explain the complete diff.
This pull request addresses one concern.
AI Disclosure
Harness: Claude Code in T3 Code
Tool(s): Claude Code subagents (code exploration and an independent diff review)
Model(s): claude-opus-5-5
Involvement: Fully AI-generated, human verified
Review: an independent review of the first version found that a capability check written beside the planner disagreed with it (container support, device quirks, downmix of native codecs) and could start on a track that is then converted to stereo. The rule now asks the planner instead, and a planner-backed test covers that case. Kody and CodeRabbit then found the missing remux escalation and the lower-version case; both are fixed with tests that fail on the earlier head.
Refine omitted audio-track selection to pick a track that plays without conversion
When a v3 start request has no explicit audio selection, PreferUnconvertedAudioTrackV3 in audio_select_v3.go can switch to a same-language, non-commentary track that plans as playable without audio conversion. Saved series track preferences are kept. Candidates must deliver at least as many channels as the original choice; ties break by channels, Atmos, then codec rank.
Adds the codec_channel_ceilings_v1 feature and an optional max_channels_by_codec map to DeliveryCapabilityV3 in protocol_v3.go. Planning in plan_v3.go uses the lower of the delivery-wide MaxChannels and the per-codec value for stream-copy and AAC output decisions.
If buffered-version selection changes the effective file, the start handler remaps the audio preference and re-evaluates it against that file.
Behavioral Change: non-native-v2 requests have max_channels_by_codec stripped before validation in playback_v3.go; an omitted audio selection may now resolve to a different same-language track than effective_audio_track_index suggests, as documented in catalog-api.md.
When a v3 start names no audio track and the preference-based default
would need an audio conversion for this request, play another main track
in the same language that the request can take unconverted. A saved
series track still plays as saved.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Protocol v3 playback start can select a playable, unconverted audio track when no explicit or saved preference determines the selection. Candidate tracks must meet language and channel requirements. Start handling also refines audio after a buffered-version change. Tests and documentation cover these behaviors.
Changes: V3 audio selection
Layer / File(s)
Summary
Planner outcomes and candidate selection internal/playback/audio_select_v3.go, internal/playback/prepare_tracks.go, internal/playback/audio_select_test.go, internal/playback/audio_select_v3_test.go
Selection helpers use planner outcomes to identify playable and converted tracks. Eligible same-language main tracks are ranked by channel count, Atmos/JOC, codec, then track order. Tests cover replacement and retention cases.
Start handling tracks whether a saved preference determined the audio choice and refines the selection when permitted, including after a buffered-version change. Tests cover lower-version refinement and escalated playback routes. Documentation describes the selection rules and the limits of effective_audio_track_index.
sequenceDiagram
participant Start as Protocol v3 start
participant Preference as preferredAudioTrackIndexV3
participant Selection as playableStartAudioV3
participant Planner as Playback planner
Start->>Preference: resolve audio index and saved status
Start->>Selection: evaluate candidates when refinement is permitted
Selection->>Planner: plan candidate playback
Planner-->>Selection: return plan or terminal result
Selection-->>Start: return selected audio index
When playback starts without a chosen audio track, the server may pick a track based on an outdated bandwidth estimate. A later replan can also restore a track that differs from the one now playing. These cases can cause unnecessary audio conversion or an unexpected track change. Fix both before merging.
Security architecture risk: Low · up to 3fd6e
The change is bounded to audio selection for playback the user can already access. Existing ownership and transport checks remain in place. Final bandwidth adjustments and recovery can use different selection contexts, so confidence in those edge cases remains limited.
Retained concerns
No architecture-level concerns identified.
Security review details
Security Blast Radius
inferred — The directly evidenced expansion is additional planning over eligible audio tracks within the selected media file, not additional authority over unrelated assets. Work scales with eligible track inventory when the original choice converts or cannot plan; its operational cost was not measured.
Trust Boundaries and Controls
observed — Client capabilities influence route selection but do not replace the existing transport-policy checks. Candidate planning derives proxy eligibility from negotiated media features and server configuration; progressive-remux escalation checks available routes under the routing policy.
Resilience and Maintainability Implications
observed — Capability or escalation failures yield an empty candidate outcome. A replacement is accepted only when it has a playable, unconverted result; if no candidate qualifies, the original choice remains subject to final planning and terminal handling.
Pre-merge checks: 4 · 1
Failed checks: 1 warning
Check name
Status
Explanation
Resolution
Docstring Coverage
Docstring coverage is 56.25% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 16 functions across 7 files.
Write docstrings for the functions missing them to satisfy the coverage threshold.
Passed checks: 4 passed
Check name
Status
Explanation
Title check
The title clearly and concisely describes the main change: selecting an audio track that the client can play without conversion.
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Description check
The pull request description directly explains the audio-track selection changes, planner-based refinement, fallback behavior, tests, validation, and documented API effects.
Finishing Touches: 💡 1
📝 Generate docstrings: 💡
Commit to this branch
Create a new PR
🧪 Generate unit tests (beta)
Commit to this branch
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Comment @coderabbitai help to get the list of available commands.
Visible change: playback can start on a same-language audio track the client plays without conversion instead of converting the preferred track. Evidence is missing (Evidence: pending); add before-and-after playback-start response excerpts or a recording for the same media and client, showing the selected track and conversion behavior, and name the surface and build or commit.
Suggested fix: replace Evidence: pending with the captures or excerpts and their surface/build details.
Automated check: Macroscope check run agent (gpt-6-luna). Evidence was not reviewed for correctness.
coderabbitaiBot
added
api-v2
API v2 / Huma migration program (epic #135); long-running, stacked by phase
evidence-required
Needs before-and-after evidence before the Evidence check passes
impact: playback
Can't play, stalls, or wrong media
impact: usability
Core flow broken or severely blocked
needs-review
Needs maintainer review to resolve uncertain classification, scope, or changed evidence.
labels
Oct 27, 2026
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
Review info
Run configuration
Source mode: Auto
Repository: Unavailable
Branch: Unavailable
File: No configuration file from this repository applied
Commit: Unavailable
Layers: Organization UI
Review profile: CHILL
Plan: Advanced
Run ID: 519399f0-bdda-4331-9a00-2055aa36f8f3
Commits
Reviewing files that changed from the base of the PR and between 8b84639 and 953e3e1.
Files selected for processing: 7
docs/architecture/playback-protocol-v3.md
docs/catalog-api.md
internal/api/handlers/playback_v3.go
internal/playback/audio_select_test.go
internal/playback/audio_select_v3.go
internal/playback/audio_select_v3_test.go
internal/playback/prepare_tracks.go
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 3 remain after this review.
The start's audio refinement now judges each track after the escalation
the start applies to a progressive remux with no route, and refines the
preference again when a buffered start moves to a lower version, instead
of carrying a track chosen on the requested file over by position.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.
Reviewing changes in Silo
Include the related issue, expected behavior, and validation steps in the PR description.
For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
Follow this repository's AGENTS.md and CONTRIBUTING.md.
Request another review with @kody start-review in a PR comment.
React with 👍 or 👎 to give feedback on individual suggestions.
Review settingsReview Options
The following review options are enabled or disabled:
Options
Enabled
Bug
✅
Performance
✅
Security
✅
Business Logic
❌
⚠️ 2 Kody Rule(s) were not evaluated
These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:
Preserve optional store capabilities through production wrappers
Detach mandatory cleanup from request cancellation and bound its lifetime
The reason will be displayed to describe this comment to others. Learn more.
Restrict the new audio-default behavior to the native v2 API
For /api/v1/playback/start requests that omit an audio track, this unconditional refinement changes the frozen bridge's selection behavior too: HandleStartPlayback calls this same application function. A TrueHD default can now become AC-3/E-AC-3, and the legacy start side effects persist that substituted track as the series preference, affecting subsequent playback on other devices. Gate the new refinement with isNativeAPIV2(r.Context()) so the v1 bridge retains its existing behavior. The repository's AGENTS.md explicitly restricts v1 changes to critical bridge-usability fixes, rather than new features.
The reason will be displayed to describe this comment to others. Learn more.
Preserve the refined audio choice through version-selection replans
When buffered version selection changes the file, this second refinement changes audioIndex but leaves the earlier intent.audioIndex pointing at the requested file's first refined track. In the new TestBufferedAutoRefinesAudioOnTheLowerVersion scenario, playback therefore starts on the lower version's TrueHD-to-5.1 conversion, but startDesiredTracksV3 stores the requested version's E-AC-3 track as the desired audio. A subsequent quality/output replan that selects the same lower version resolves that stale desired track through lowerBufferedVersionForIntent to stereo AAC, without running this refinement again. Keep the durable audio intent and replan refinement consistent so an unrelated replan does not silently downgrade 5.1 playback to stereo.
A regular code review gets triggered (for example, "@codex review" or when a PR is opened), and you’re opted in so security review runs alongside code review
Once complete, Codex will leave suggestions, or a comment if no findings are found.
Security: Bound audio-track planning work per playback start
When an authenticated viewer starts an accessible imported file without naming an audio track, they control capabilities that can make the preferred track require conversion. For a file containing many same-language audio streams, this loop invokes the full route planner for every eligible stream; scanner ingestion persists all ffprobe streams without a count bound, and session admission happens only afterward. Repeated starts with fresh attempt IDs can therefore monopolize API CPU. Cap the candidate/planning budget and reject or truncate pathological stream inventories before calling outcome.
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.
applyConnectionReading and applyLearnedLimit can change the request estimate after the first playableStartAudioV3 call. The planner uses that estimate to select the delivery route and audio conversion. The final planStartV3 call uses the updated request, but its audioIndex can still come from the earlier route.
lowerBufferedVersion replans candidates with the updated request, but it only remaps the existing audio selection. It does not rerun playableStartAudioV3. Its later refinement runs only when the effective version changes. Re-run audio refinement against the updated request before the final plan, using the original requested-file preference as the baseline for version remapping.
Persist the final audio intent after lower-version refinement.
The buffered-version branch can select a different audio track after intent is captured. startDesiredTracksV3 then saves the earlier requested-file track instead of the track used by the final plan. A later replan can restore that earlier track without a viewer selection.
Persist a snapshot of the final selected audio track for this server-selected path while preserving the existing requested-file intent for explicit or saved selections.
* feat(playback): accept per-codec audio channel ceilings
A delivery's max_channels applies to every codec, so a client that decodes
AAC only in stereo but plays E-AC-3 5.1 had to cap both. The new optional
max_channels_by_codec caps one codec on top of max_channels: {"aac": 2}
keeps AAC conversions in stereo and still copies E-AC-3 5.1. /api/v2
advertises codec_channel_ceilings_v1.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
* fix(playback): keep a codec ceiling over an unset spelling
When two spellings of one codec meet in max_channels_by_codec, a positive
ceiling now wins over zero or less (unset), and the lowest positive one
over the rest. The OpenAPI schema states the 32-entry limit.
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---------
Co-authored-by: Claude Opus 5.5 <[email protected]>
silo-triageBot
added
size/XL
500–999 added + deleted lines (all files); change volume, not priority.
and removed
size/L
200–499 added + deleted lines (all files); change volume, not priority.
labels
Oct 27, 2026
Review finished. Check the inline comments for findings and verify each suggestion against the code and tests.
Reviewing changes in Silo
Include the related issue, expected behavior, and validation steps in the PR description.
For API changes, describe the effect on Apple and Android clients and Jellyfin compatibility.
For plugin changes, identify the affected SDK contract, plugin, and catalog entry.
Follow this repository's AGENTS.md and CONTRIBUTING.md.
Request another review with @kody start-review in a PR comment.
React with 👍 or 👎 to give feedback on individual suggestions.
Review settingsReview Options
The following review options are enabled or disabled:
Options
Enabled
Bug
✅
Performance
✅
Security
✅
Business Logic
❌
⚠️ 2 Kody Rule(s) were not evaluated
These rules declare that they need repository context beyond this diff, and the review could not retrieve it, so they were not judged on this pull request:
Preserve optional store capabilities through production wrappers
Detach mandatory cleanup from request cancellation and bound its lifetime
The Validation tasks: line should identify task cases, not parent #1249 or only legacy #197. #197 is the old Movies — Server issue and has no numbered Cases/Results; #1249 is a parent. The current Series and Audiobooks playback cases that exercise this behavior have no recorded run yet.
The PR's explicit-track statement applies to Apple/Android video starts, but not audiobook starts: Apple sets both track fields to nil and Android passes null; both use Protocol V3. Web's initial no-pick start also omits the track. Please replace the line with:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
api-v2API v2 / Huma migration program (epic #135); long-running, stacked by phaseenhancementNew feature or requestevidence-requiredNeeds before-and-after evidence before the Evidence check passesgoPull requests that update go codeimpact: playbackCan't play, stalls, or wrong mediaimpact: usabilityCore flow broken or severely blockedneeds-reviewNeeds maintainer review to resolve uncertain classification, scope, or changed evidence.priority: P2Limited scope, workaround exists, or polishsize/XL500–999 added + deleted lines (all files); change volume, not priority.
1 participant
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Related issue: N/A
Validation tasks: no passed case is reached; touches #197 (Playback) and #1249 CORE3, neither run yet
When a client starts playback without naming an audio track, the server picks one by the profile's language and the file's default flag, without looking at what the client can play. For a file whose default is TrueHD 7.1 Atmos beside an English E-AC-3 or AC-3 5.1 track, a Roku (no TrueHD, no multichannel AAC) gets the TrueHD track converted to stereo AAC, while the 5.1 track it could play as it is goes unused. Other clients that cannot take the default have the same problem.
With this change, a v3 start that names no track still resolves the profile's preference first. If the plan for that track converts its audio (or does not plan), and the plan for another main track in the same language plays it unconverted with at least as many channels, the server starts on that track. A track the viewer saved for the series still plays as saved. A client that plays TrueHD keeps it.
Approach
playback.PreferUnconvertedAudioTrackV3holds the rule. It takes anoutcomefunction that plans the file with one track and reports whether the route plays, converts the audio, and how many channels reach the client. The planner is the authority, so container support, device quirks, and video routes that re-encode every track all count.preferredAudioTrackIndexV3now also reports whether the saved series track decided (playback.SavedAudioTrackChosen). When it did not, the start handler callsplayableStartAudioV3after loading planner settings, which plans the requested file once for the chosen track and, only if that converts, once per same-language candidate. Each plan goes through the escalation the start applies to a progressive remux with no route (escalateRefusedProgressiveRemuxV3). When a buffered Auto start then moves to a lower version (lowerBufferedVersion), the preference is refined again on that version rather than carried over by position.effective_audio_track_indexin catalog reads is unchanged and still knows no device. The protocol doc now says a client omits the track when the viewer has not picked one, rather than echoing that index; the plan'sselected_tracksnames what plays.Apple and Android currently send the effective index back as an explicit track, so they keep today's behavior until they omit it. Follow-ups for both are drafted. jellycompat already has its own fallback from TrueHD to a same-language E-AC-3 or AC-3 track and is unchanged.
Validation
TestPlayableStartAudioV3JudgesTheEscalatedRoute(a candidate that only looks copied before escalation) andTestBufferedAutoRefinesAudioOnTheLowerVersion(a lower version whose matching track by position is stereo).go build,gofmt,go vet,make lint-changed,make test-go(twojellycompatDV-strip tests fail locally onmaintoo and pass in CI), and the playback-fixture, API v2, route-inventory, and other generated-contract checks.Evidence
Evidence: https://evidence.siloserver.org/r/silo-server/pr-3115/
Risks
MatchAudioTrackAcrossVersions, as an explicit pick would be. The refinement changes nothing in that case, since no track on the requested file plans.Checklist
AI Disclosure
🤖 Generated with Claude Code
Note
Refine omitted audio-track selection to pick a track that plays without conversion
PreferUnconvertedAudioTrackV3in audio_select_v3.go can switch to a same-language, non-commentary track that plans as playable without audio conversion. Saved series track preferences are kept. Candidates must deliver at least as many channels as the original choice; ties break by channels, Atmos, then codec rank.codec_channel_ceilings_v1feature and an optionalmax_channels_by_codecmap toDeliveryCapabilityV3in protocol_v3.go. Planning in plan_v3.go uses the lower of the delivery-wideMaxChannelsand the per-codec value for stream-copy and AAC output decisions.max_channels_by_codecstripped before validation in playback_v3.go; an omitted audio selection may now resolve to a different same-language track thaneffective_audio_track_indexsuggests, as documented in catalog-api.md.Macroscope summarized 36ac38d.