Skip to content

feat(playback): start on an audio track the client plays without conversion - #3115

Merged
Quick104 merged 3 commits into
mainfrom
feat/playable-audio-default
Oct 27, 2026
Merged

Quick104 merged 3 commits into
mainfrom
feat/playable-audio-default

Conversation

@Quick104

@Quick104 Quick104 commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

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

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/pr-3115/

Risks

  • 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.

🤖 Generated with Claude Code

Note

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.

Macroscope summarized 36ac38d.

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]>
@silo-triage silo-triage Bot added the size/L 200–499 added + deleted lines (all files); change volume, not priority. label Oct 26, 2026
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-27T00:29:50.478798Z 36ac38d New commits
🔒 Security Review ✅ Completed 2026-10-27T00:32:13.757052Z 36ac38d New commits

Security findings

Advisory findings (1)

ℹ️ 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" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@silo-kody

silo-kody Bot commented Oct 26, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

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 settings
Review Options

The following review options are enabled or disabled:

Options Enabled
Bug ✅
Performance ✅
Security ✅
Business Logic ❌

@coderabbitai

coderabbitai Bot commented Oct 26, 2026 •

Copy link
Copy Markdown
Contributor

Review in Change Stack →

Walkthrough

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.
Preference-aware start integration
internal/api/handlers/playback_v3.go, internal/api/handlers/playback_connection_test.go, internal/api/handlers/playback_v3_tokenless_test.go, docs/architecture/playback-protocol-v3.md, docs/catalog-api.md
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.

Priority: Normal

Estimated code review effort: 3 (Moderate) | ~25 minutes

Change: Feature

Sequence Diagram(s)

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
Loading

Possibly related issues

Possibly related PRs

  • Silo-Server/silo-server#3009: Both changes define how saved audio preferences affect protocol v3 track selection across version changes.
  • Silo-Server/silo-server#3116: Planner channel ceilings can affect whether audio is converted, which this change uses to choose an alternate track.

Suggested labels: api-v2, impact: playback, impact: usability, evidence-required, needs-review

Merge Risk: Moderate · up to 3fd6e

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: Passed 4 · Failed 1

Failed Failed checks: 1 warning

Check name Status Explanation Resolution
Docstring Coverage Warning 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 Passed checks: 4 passed
Check name Status Explanation
Title check Passed The title clearly and concisely describes the main change: selecting an audio track that the client can play without conversion.
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Description check Passed 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.

@macroscopeapp

macroscopeapp Bot commented Oct 26, 2026

Copy link
Copy Markdown

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.

Posted via Macroscope — Visible change evidence

@silo-triage silo-triage Bot added enhancement New feature or request go Pull requests that update go code priority: P2 Limited scope, workaround exists, or polish labels Oct 26, 2026
@coderabbitai coderabbitai Bot 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
Comment thread internal/api/handlers/playback_v3.go Resolved

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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.

Comment thread internal/api/handlers/playback_v3.go Resolved
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]>
@silo-kody

silo-kody Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

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 settings
Review 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

@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: 3fd6e99064

ℹ️ 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 +1984 to +1985
if serverAudio && settingsErr == nil {
audioIndex = h.playableStartAudioV3(r.Context(), req, requestedFile, requestedFile, audioIndex, settings)

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P1 Badge 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.

AGENTS.md reference: AGENTS.md:L260-L261

Useful? React with 👍 / 👎.

Comment on lines +2048 to +2051
if serverAudio && settingsErr == nil && effectiveFile != bufferedBase {
// A track refined on the requested file means little on another
// version: refine the preference again on the one that plays.
audioIndex = h.playableStartAudioV3(r.Context(), req, requestedFile, effectiveFile, remapAudioIndexV3(requestedFile, effectiveFile, preferredAudio), settings)

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

Useful? React with 👍 / 👎.

@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 Security Review · Automatically triggered

Here are some automated security review suggestions for this pull request.

Reviewed commit: 3fd6e99064

ℹ️ About Codex security reviews in GitHub

This is an experimental Codex feature. Security reviews are triggered when:

  • You comment "@codex security review"
  • 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.

!AudioTrackDecodable(tracks, i, file.CodecAudio) {
continue
}
candidate := outcome(i)

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 Security Review · Automatically triggered

P2 Badge 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.

Useful? React with 👍 / 👎.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 2


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: b82ea561-a1b0-4089-a649-e83cef46414f
Commits

Reviewing files that changed from the base of the PR and between 953e3e1 and 3fd6e99.

Files selected for processing: 3
  • internal/api/handlers/playback_connection_test.go
  • internal/api/handlers/playback_v3.go
  • internal/api/handlers/playback_v3_tokenless_test.go

Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 1 remain after this review.

// switch to another version refines again on that version.
preferredAudio := audioIndex
if serverAudio && settingsErr == nil {
audioIndex = h.playableStartAudioV3(r.Context(), req, requestedFile, requestedFile, audioIndex, settings)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Major · Functional Correctness · Heavy lift

Supported by static analysis

Script executed:

rg -n 'applyConnectionReading|applyLearnedLimit|playableStartAudioV3|lowerBufferedVersion|planStartV3' internal/api/handlers/playback_v3.go
sed -n '1960,2070p' internal/api/handlers/playback_v3.go

Repository: Silo-Server/silo-server

Length of output: 8634


Script executed:

set -eu
printf '%s\n' '--- planStartV3 ---'
sed -n '1735,1815p' internal/api/handlers/playback_v3.go
printf '%s\n' '--- playableStartAudioV3 ---'
sed -n '3795,3925p' internal/api/handlers/playback_v3.go
printf '%s\n' '--- lowerBufferedVersion and request mutators ---'
rg -n -F -- 'func (h *PlaybackHandler) lowerBufferedVersion' 'func (h *PlaybackHandler) applyConnectionReading' 'func (h *PlaybackHandler) applyLearnedLimit' internal/api/handlers/playback_v3.go
sed -n '5600,5705p' internal/api/handlers/playback_v3.go
sed -n '5705,5840p' internal/api/handlers/playback_v3.go
printf '%s\n' '--- request-field definitions and planner consumers ---'
rg -n -F -- 'ObservedBandwidth' 'BandwidthEstimate' 'BandwidthCap' 'MaxBitrate' 'planStartV3(' internal/api/handlers internal/playback | head -120

Repository: Silo-Server/silo-server

Length of output: 11847


Script executed:

set -eu
printf '%s\n' '--- helper locations ---'
rg -n -F -- 'func (h *PlaybackHandler) lowerBufferedVersion' internal/api/handlers/playback_v3.go
rg -n -F -- 'func (h *PlaybackHandler) applyConnectionReading' internal/api/handlers/playback_v3.go
rg -n -F -- 'func (h *PlaybackHandler) applyLearnedLimit' internal/api/handlers/playback_v3.go
printf '%s\n' '--- request-field references ---'
rg -n -F -- 'BandwidthEstimate' internal/api/handlers internal/playback || true
rg -n -F -- 'ObservedBandwidth' internal/api/handlers internal/playback || true
rg -n -F -- 'BandwidthCap' internal/api/handlers internal/playback || true
rg -n -F -- 'MaxBitrate' internal/api/handlers internal/playback || true
printf '%s\n' '--- planner outcome symbols ---'
rg -n -F -- 'StartAudioOutcomeFromResultV3' internal/playback internal/api/handlers
rg -n -F -- 'PreferUnconvertedAudioTrackV3' internal/playback internal/api/handlers
rg -n -F -- 'lowerBufferedVersion' internal/api/handlers/playback_v3.go

Repository: Silo-Server/silo-server

Length of output: 186


Script executed:

printf '%s\n' '--- all helper references ---'
rg -n -F -- 'applyConnectionReading' internal/api/handlers internal/playback || true
rg -n -F -- 'applyLearnedLimit' internal/api/handlers internal/playback || true
rg -n -F -- 'lowerBufferedVersion' internal/api/handlers internal/playback || true
printf '%s\n' '--- planner symbols ---'
rg -n -F -- 'StartAudioOutcomeFromResultV3' internal/playback internal/api/handlers || true
rg -n -F -- 'PreferUnconvertedAudioTrackV3' internal/playback internal/api/handlers || true
printf '%s\n' '--- request bandwidth-like fields ---'
rg -n -i -- 'bandwidth|bitrate.*cap|observed.*estimate|learned.*limit' internal/api/handlers/playback_v3.go internal/playback | head -240 || true

Repository: Silo-Server/silo-server

Length of output: 37751


Script executed:

set -eu
printf '%s\n' '--- playback_connection.go ---'
sed -n '1,235p' internal/api/handlers/playback_connection.go
printf '%s\n' '--- audio_select_v3.go ---'
sed -n '1,115p' internal/playback/audio_select_v3.go
printf '%s\n' '--- planner audio route conditions ---'
sed -n '1040,1160p' internal/playback/plan_v3.go
printf '%s\n' '--- planner request bandwidth conditions ---'
sed -n '1270,1325p' internal/playback/plan_v3.go
sed -n '1780,1880p' internal/playback/plan_v3.go

Repository: Silo-Server/silo-server

Length of output: 31145


Script executed:

set -eu
sed -n '220,340p' internal/api/handlers/playback_connection.go
rg -n -F -- 'func (h *PlaybackHandler) bufferedCandidateTracksV3' internal/api/handlers/playback_connection.go internal/api/handlers/playback_v3.go
rg -n -F -- 'bufferedCandidateTracksV3' internal/api/handlers/playback_connection.go internal/api/handlers/playback_v3.go

Repository: Silo-Server/silo-server

Length of output: 4252


Refine audio after bandwidth updates.

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.

if serverAudio && settingsErr == nil && effectiveFile != bufferedBase {
// A track refined on the requested file means little on another
// version: refine the preference again on the one that plays.
audioIndex = h.playableStartAudioV3(r.Context(), req, requestedFile, effectiveFile, remapAudioIndexV3(requestedFile, effectiveFile, preferredAudio), settings)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Major · Functional Correctness · Heavy lift

Supported by static analysis

Script executed:

set -eu
file=internal/api/handlers/playback_v3.go
printf '%s\n' '--- changed hunk and surrounding start flow ---'
git diff --unified=80 8b84639edde68289c8877a0ea101a7da414549ce 3fd6e9906493826b60d2fafdcd2567964c40ee01 -- "$file" | sed -n '1,360p'
printf '%s\n' '--- intent/helper references ---'
rg -n -F -- 'startDesiredTracksV3' "$file"
rg -n -F -e 'intent.audioIndex' -e 'playableStartAudioV3' -e 'preferredAudioTrackIndexV3' "$file"
printf '%s\n' '--- helper definitions and callers ---'
sed -n '1880,2105p' "$file"
rg -n -F -e 'func (h *PlaybackHandler) startDesiredTracksV3' -e 'func startDesiredTracksV3' -e 'startDesiredTracksV3(' "$file"
printf '%s\n' '--- matching tests ---'
rg -n -F -e 'lower' -e 'buffered' -e 'audioIndex' internal/api/handlers/*test.go | grep -E 'playback_v3|Playback|Start' | head -160 || true

Repository: Silo-Server/silo-server

Length of output: 41832


Script executed:

set -eu
printf '%s\n' '--- helper definition and all references ---'
rg -n -F --glob '*.go' -e 'startDesiredTracksV3' -e 'DesiredTracks' internal
printf '%s\n' '--- nearby startDesiredTracksV3 definition ---'
hits=$(rg -l -F --glob '*.go' -- 'startDesiredTracksV3' internal | head -1)
if [ -n "$hits" ]; then
  file="$hits"
  line=$(rg -n -F -- 'startDesiredTracksV3' "$file" | tail -1 | cut -d: -f1)
  start=$((line-80)); [ "$start" -lt 1 ] && start=1
  end=$((line+180))
  sed -n "${start},${end}p" "$file"
fi
printf '%s\n' '--- replan paths reading desired tracks ---'
rg -n -F --glob '*.go' -e 'DesiredTracks.Audio' -e 'desiredTracks.Audio' -e 'DesiredTracks' internal/api internal/playback | head -220

Repository: Silo-Server/silo-server

Length of output: 23783


Script executed:

set -eu
printf '%s\n' '--- desired audio identity and resolver ---'
sed -n '1,180p' internal/playback/desired_tracks_v3.go
rg -n -F --glob '*.go' -e 'func DesiredAudioFromFile' -e 'func (.*ResolveOn' internal/playback
printf '%s\n' '--- refinement implementation and references ---'
rg -n -F --glob '*.go' -e 'playableStartAudioV3' -e 'preferredAudio' internal/api/handlers
printf '%s\n' '--- focused changed tests and nearby assertions ---'
git diff --unified=30 8b84639edde68289c8877a0ea101a7da414549ce 3fd6e9906493826b60d2fafdcd2567964c40ee01 -- 'internal/api/handlers/*test.go' | grep -n -C 12 -E 'audio|buffer|lower|preferred|unconverted' | head -260 || true

Repository: Silo-Server/silo-server

Length of output: 15596


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-triage silo-triage Bot 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
@silo-kody

silo-kody Bot commented Oct 27, 2026 •

Copy link
Copy Markdown

Silo Kody — review complete

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 settings
Review 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

@Quick104
Quick104 merged commit e7605af into main Oct 27, 2026
9 of 10 checks passed
@Quick104
Quick104 deleted the feat/playable-audio-default branch October 27, 2026 00:28
@macroscopeapp

macroscopeapp Bot commented Oct 27, 2026

Copy link
Copy Markdown

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:

Validation tasks: changes #1250 C5; changes #1252 C3; changes #1254 C5; changes #1256 C3; changes Silo-Server/silo-apple#339 C3; changes Silo-Server/silo-apple#340 C3; changes Silo-Server/silo-android#349 C3; changes Silo-Server/silo-android#350 C3

No prior result needs re-validation: #1196 C1 checks policy enforcement, and #193 S3 rejects restricted files before the new audio-selection step.

Automated check: Macroscope check run agent (gpt-6-luna). No validation was performed.

Posted via Macroscope — v1 validation impact

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

Labels

api-v2 API v2 / Huma migration program (epic #135); long-running, stacked by phase enhancement New feature or request evidence-required Needs before-and-after evidence before the Evidence check passes go Pull requests that update go code 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. priority: P2 Limited scope, workaround exists, or polish size/XL 500–999 added + deleted lines (all files); change volume, not priority.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant