Skip to content

fix(jellycompat): run local transcodes on the configured hw_device - #5923

Open
Quick104 wants to merge 1 commit into
mainfrom
fix/jellycompat-hw-device
Open

Quick104 wants to merge 1 commit into
mainfrom
fix/jellycompat-hw-device

Conversation

@Quick104

@Quick104 Quick104 commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Problem

Related issue: N/A
Validation tasks: none

Other clients: N/A (no client-visible change)

When playback.hw_device is set, Jellyfin clients' transcodes on the API host ignore it. Native playback passes the configured device to execution, but jellycompat leaves HWDevice empty both when it starts a local transcode and in the runtime config its transcode manager uses to rebuild sessions. Execution then picks the device detection verified, or the first render node.

Two things go wrong for hosts with a configured device:

  • A multi-device list is never balanced for Jellyfin-client sessions. They all land on one GPU.
  • With an explicit hw_accel (qsv or vaapi) and one configured device, the transcode opens the first render node instead. Jellyfin-client tone-map planning probes the configured device, so the plan and the GPU that runs it can differ.

Approach

A new localHWDevice() on the jellycompat playback handler returns playback.hw_device from the handler's config, the same value the tone-map probe already reads. The local start options and the transcode manager's runtime config both use it, matching the native path.

Remote dispatch is unchanged. A remote node still resolves its own device, and moving a session to another node still clears the recorded device.

Validation

  • Focused test: starts a Jellyfin-client transcode through the handler with a fake ffmpeg, hw_accel=vaapi, and one configured device. It checks the rebuild runtime config and the started session's resolved device. On the base it fails both checks. With only the start-path change reverted, the session opened the first render node instead of the configured one, which is the reported trigger.
  • internal/jellycompat and internal/playback test packages pass. make lint-changed reports 0 issues.
  • Not reproduced on hardware. No GPU host was used.

Evidence

Evidence: https://evidence.siloserver.org/r/silo-server/jellycompat-hw-device/

Risks

A host that sets playback.hw_device now runs Jellyfin-client transcodes on that device, as native playback already does. Hosts without it see no change. playback.hw_device stays restart-required for this handler, as before.

Checklist

  • I read and can explain the complete diff.
  • This pull request addresses one concern.
  • Each test this pull request adds meets "Decide what to test" in CONTRIBUTING.md.
  • The Evidence section shows every change a user can see, or how I checked a change nobody sees.

Council review

Ran as a follow-up of the review of #5920: no plan round (one-field wiring fix, skipped as mechanical) and one background reviewer.

Rounds: 1, last reviewed b155aff

Member Round 1
Sol (gpt-6.2-sol, medium) 8/10

Answered: S1 (the allocator can pick a configured render node the process can't open) predates this change; native playback hits it through the same allocator. Filed as #5924, to follow #5920.

AI Disclosure

  • Harness: Claude Code in T3 Code
  • Tool(s): Claude Code subagents for code review
  • Model(s): claude-opus-5-5 (implementation and review), claude-sonnet-5-5 (review subagents), gpt-6.2-sol (background review)
  • Involvement: Fully AI-generated; not yet human verified
  • Adversarial review: code review at medium (three finders and a validation check) found no correctness defect; the background review is in the Council review section above.

🤖 Generated with Claude Code

Jellyfin-protocol transcodes on the API host built their TranscodeOpts and
the transcode manager's runtime config without playback.hw_device. Execution
then fell back to the first verified or first render node, so a multi-device
list was never balanced for these sessions, and a single configured device
was ignored while jellycompat's own tone-map probe tested it.

Read the same boot config the probe reads for both the start opts and the
reconstruction runtime. Remote dispatch is unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@silo-triage silo-triage Bot added the size/M 50–199 added + deleted lines (all files); change volume, not priority. label Dec 6, 2026
@silo-kody

silo-kody Bot commented Dec 6, 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 ❌

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Dec 6, 2026 •

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-12-06T07:56:25.601562Z b155aff PR opened
🔒 Security Review ✅ Completed 2026-12-06T07:58:06.435348Z b155aff PR opened
ℹ️ 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-triage silo-triage Bot added bug Something isn't working go Pull requests that update go code impact: compat Breaks a supported client or server path priority: P2 Limited scope, workaround exists, or polish triaged High-confidence review completed; does not mean fixed, validated, or accepted for release. labels Dec 6, 2026
@coderabbitai

coderabbitai Bot commented Dec 6, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

No actionable comments were generated in the recent review.

Walkthrough

The compatibility playback handler now passes the configured playback hardware device to transcode runtime configuration and compatibility transcode options. A test verifies the device value in the handler configuration and a locally created compatibility transcode session.

Changes: Playback hardware device propagation

Layer / File(s) Summary
Read and propagate the playback hardware device
internal/jellycompat/handlers_playback.go, internal/jellycompat/streams.go, internal/jellycompat/local_hw_device_test.go
The handler returns the configured playback hardware device, or an empty string when its config is nil. Both transcode paths use this value. The test checks the configured device in the handler configuration and a locally created compatibility transcode session.

Estimated code review effort: 2 (Simple) | ~10 minutes

Change: Bug fix

Suggested labels: bug, go

Suggested reviewers: blurbery, rangodj

Merge Risk: Minimal · up to b155a

Local Jellyfin-client transcodes now use the configured hardware device. Hosts without the setting see no change. No merge-blocking risk remains.

Security architecture risk: Minimal · up to b155a

Jellyfin-compatible transcodes on the API host now honor the configured playback GPU when starting or rebuilding a session. This changes which configured GPU runs the work, not which clients can request a transcode or which host executes it. No material regression in security or recovery was identified.

Security review details

Security Blast Radius

  • inferred — Existing Jellyfin playback requests can now cause local work on additional operator-configured GPUs. The scope is the eligible devices available to FFmpeg on the API host; the change does not grant new device permissions or add a client-controlled hardware target.

Trust Boundaries and Controls

  • observed — The device value comes from server configuration, not from Jellyfin request data. Playback resolves it before passing the concrete device to FFmpeg’s hardware initialization arguments.

Public contracts

  • observed — The changed line inside NewPlaybackHandler populates an existing runtime field. It adds no client request field, route, constructor parameter, or configuration key.

Service and deployment topology

  • observed — The new device propagation applies to transcodes on the API host. Remote dispatch is unchanged, and relocation clears hardware-specific recipe fields before storing the recipe for the new executor.

Data and control flow

  • observed — The handler reads the boot configuration for both local start options and the transcode manager callback. Reconstruction overwrites the device derived from the recipe with the runtime setting before executor validation and launch.

Resilience and Maintainability Implications

  • observed — Device selection and reservation are atomic for concurrent starts. Startup errors release the reservation, and a launched FFmpeg process releases it after exit, before completion is signaled. An in-place restart keeps the concrete device but acquires a separate reservation; reconstruction instead uses runtime configuration and may select another device. This accounts for work without promising GPU affinity across reconstruction.

Rollout and rollback

  • inferred — Operators should verify that configured devices are accessible to FFmpeg on the API host before rollout: a value Jellyfin compatibility previously ignored now affects its starts and rebuilds. The allocator filters lists by device presence and uses available verification results, but an explicit single device passes through to FFmpeg. To restore automatic selection for Jellyfin-compatible playback, clear the setting and restart the API service. The setting is shared, so clearing it can also affect other playback workloads.
Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed The title names the main change: local Jellyfin-client transcodes on the API host now use the configured playback.hw_device, which matches the raw summary (localHWDevice wired into streams.go and the …
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 description explains the problem (jellycompat leaves HWDevice empty for local transcodes and in the transcode manager's runtime config, so a configured playback.hw_device is ignored), the approach…
Full details: Title check

Explanation

The title names the main change: local Jellyfin-client transcodes on the API host now use the configured playback.hw_device, which matches the raw summary (localHWDevice wired into streams.go and the playback handler) and the PR objectives. It is specific and follows the conventional prefix style.

Full details: Description check

Explanation

The description explains the problem (jellycompat leaves HWDevice empty for local transcodes and in the transcode manager's runtime config, so a configured playback.hw_device is ignored), the approach (a new localHWDevice() helper feeding the start options and runtime config), the remote-dispatch behavior that stays unchanged, validation with a focused test, and risks. It matches the raw summary of changes in handlers_playback.go, streams.go, and the new local_hw_device_test.go. The description is related to the changeset and is specific enough to decide.

Finishing Touches

Generate unit tests (beta)

  • Commit to this branch
  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Recent 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: 88ad86f3-1bd5-426a-a3a8-2f171a6d8f2c
Commits

Reviewing files that changed from the base of the PR and between 835131f and b155aff.

Files selected for processing: 3

  • internal/jellycompat/handlers_playback.go
  • internal/jellycompat/local_hw_device_test.go
  • internal/jellycompat/streams.go

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

@Quick104 Quick104 left a comment

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Adversarial review (gpt-6.2-sol, reviewed b155aff)

One finding inline. I verified the device selection path in source and checked that a path can pass stat while opening it fails. I did not run the scenario on a GPU.

AI disclosure: gpt-6.2-sol via Codex.

Comment thread internal/jellycompat/streams.go Resolved
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working go Pull requests that update go code impact: compat Breaks a supported client or server path priority: P2 Limited scope, workaround exists, or polish size/M 50–199 added + deleted lines (all files); change volume, not priority. triaged High-confidence review completed; does not mean fixed, validated, or accepted for release.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant