Skip to content

Audio: one language precedence for every pick, and the file's default outranks a built-in English - #210

Merged
GLinnik21 merged 2 commits into
mainfrom
fix/audio-language-203
Sep 23, 2026
Merged

GLinnik21 merged 2 commits into
mainfrom
fix/audio-language-203

Conversation

@GLinnik21

@GLinnik21 GLinnik21 commented Sep 23, 2026 •

Copy link
Copy Markdown
Collaborator

With no Plex language preference, the audio pick ranked any direct-playable English track above the file's default-flagged track. The re-encode pick also fell back to a hard-coded "eng" after the show's language. So a French user's French-default MKVs opened in English whenever an English track existed (#202).

What changed

  • One precedence, in one place. audio_intents (route/plan.rs) ranks what an audio pick honours: a real per-part pick (selected and not the default echo) > the Plex language preferences in order (AudioLangPrefs, which holds only the show's audioLanguage for now) > the file's default. Every path walks that ranking and takes the first entry it can carry:
    • direct play (pick_dp_audio_pref): the pick if it can direct-play, else a direct-playable track in its language; a preference's direct-playable track; the file's default; then any direct-playable track;
    • re-encode (encode_audio_id): the pick itself (DTS gets encoded); the preference's track, keeping the direct-play pick when it is already in that language; otherwise the direct-play pick, so a quality drop keeps the language.
    • remux, MDE /decision and the remux probe use the direct-play result.
  • PREF_AUDIO_LANG is gone, so there is no built-in language anywhere.
  • Fixed a disagreement between the paths: a real pick that cannot direct-play (English DTS), combined with a show preference, used to direct-play the show's language while a re-encode named the DTS. Also, a pick that direct play cannot carry now falls to the next preference instead of going straight to the file default.
  • lang_matches now compares any two tags over one spelling table, so a fre pick finds its fra sibling.
  • A show audioLanguage / subtitleLanguage of "-1" (Plex's "Account default") is now unset, the same as "".

Subtitles were checked. They have no built-in language: the server's selection wins, then the show's language and mode, otherwise subtitles stay off.

Not in this PR: the account's defaultAudioLanguage

This PR does not yet do #203's step 3 (the account default). It needs more than a contained change. A managed Home profile's plex.tv token is dropped right after the switch: auth.rs uses it for one /api/v2/resources and never stores it (see the Session::account_token doc). UserRef.token is the PMS token. So the resolve cannot ask plex.tv for the active profile's /api/v2/user without the session layer keeping either that token or the preference. Doing that means a persisted UserRef/profile field, the switch path in auth.rs, and a refresh on profile change. Once it lands, it fits into this PR's mechanism as one more AudioLangPrefs field, after show.

Tests

  • Red first. Against the unfixed code, the_files_default_track_wins_without_a_language_preference, a_reencode_without_a_preference_keeps_the_files_default_language and a_non_playable_pick_is_answered_by_a_sibling_in_its_language all FAILED (English chosen); they pass now.
  • New: a_real_pick_outranks_the_show_language_on_every_path, an_uncarriable_pick_falls_to_the_show_language_before_the_default, a_picks_sibling_matches_across_iso_639_spellings, an_account_default_show_setting_is_no_preference. The English-assuming tests (ladder table, re-encode, and the two build_stream 720p tests) were rewritten for the file-default rule.
  • Gates on the committed tree: route:: 167 passed; --no-default-features check is clean; make check passed 4201 / 4252 / 101 with 0 failed.

Codex review

Two rounds (gpt-6-astra, high).

  • Round 1: two P2 findings, both fixed: an uncarriable pick skipped the show language, and sibling matching ignored ISO-639 aliases. Stale "English" comments were also fixed.
  • Declined:
    • folding env.audio_sid into the ranking: it is session continuity for a mid-play re-encode, not a language preference;
    • a build_stream-level preference test: the fixture PMS serves no Setting[], and the precedence is covered on the pure functions.
  • Round 2: Codex closed both findings, accepted both declines, confirmed the precedence has one authority for DP, re-encode, remux, MDE and the probe, and reported no new findings.

Refs #203 (the account-default half stays open; see above)
Closes #202

🤖 Generated with Claude Code

GLinnik21 and others added 2 commits September 23, 2026 15:05
With no Plex language preference, the direct-play ladder picked any
direct-playable English track ahead of the file's default-flagged one,
and the re-encode path chained a hard-coded "eng" after the show's
language. A French user's French-default MKVs opened in English
whenever an English track existed (#202).

The precedence now lives in one place, audio_intent: a real per-part
pick (selected, not the default echo) > the Plex language preferences
in order (AudioLangPrefs; today the show's audioLanguage, the account
default slots in after it) > the file's default. The direct-play pick
and the remux/re-encode pick both resolve that one answer and differ
only in how they carry it:
- direct play: the pick if direct-playable, else a direct-playable
  track in its language; a preference's direct-playable track; then
  the file's default; then any direct-playable track;
- re-encode: the pick itself; the preference's track (keeping the
  direct-play pick when it is already in that language); otherwise the
  direct-play pick, so a quality drop keeps the language.

This also closes a disagreement between the two paths: a non-playable
real pick (English DTS) with a show preference used to direct-play the
show's language while a re-encode named the DTS. PREF_AUDIO_LANG is
gone, and a show setting of "-1" (Account default) is now unset like "".

Refs #202, #203

Co-Authored-By: Claude Opus 5.5 <[email protected]>
… test

Review follow-up. audio_intent returned a single answer, so a real pick
that direct play could not carry (French DTS, no playable French track)
skipped the show's language and fell straight to the file's default.
audio_intents now returns the whole ranking (pick > preferences in
order > file default) and both the direct-play and the remux/re-encode
pick take the first entry they can carry.

A picked stream's sibling was matched by raw code equality, so a `fre`
pick missed its `fra` sibling. lang_matches now compares any two tags
(preference or stream code) over one spelling table, and serves both.

Refs #203

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Sep 23, 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-09-23T12:48:56.224806Z 0ee0cd4 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.

@GLinnik21
GLinnik21 merged commit 454733d into main Sep 23, 2026
5 checks passed
@GLinnik21
GLinnik21 deleted the fix/audio-language-203 branch September 23, 2026 13:24
GLinnik21 added a commit that referenced this pull request Sep 24, 2026
…evice-pass fixes, release note and audit (#233)

Ports the three release/v0.6 fixes that never reached trunk (ambiguous bare IPv6 redaction, webOS/hardware context on handled playback events, crash-log mark identity binding and bounded read); discloses what offline mode keeps per profile in PRIVACY.md and the in-app Privacy page; fixes the replay-after-EOS dev arm (regression from 235e519), the harness batch abort on a missing stored sign-in, audio_switch_native's pre-#210 premise, and stale C objects when src/config.local.h disappears; grades the storage helper's firmware compatibility for releases; adds the v0.7.0 release note and audit.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

PLX-Native 0.6.6 on LG TV OLED55C8PLA (firmware 05.50.70) selects English audio as a priority

1 participant