From d05ae85077e1579498a94d9cc4c33c2b82dd74eb Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Thu, 13 Aug 2026 11:10:13 +0000 Subject: [PATCH] fix(playback): restore SDR alternate fallback for burn-in subtitles #617 renamed HDR/4K burn-in refusals to subtitle_conversion_unsupported when the subtitle alone forced adaptation, but terminalAllowsAlternateFileV3 still only recognized the old HDR/4K reasons. Selecting a PGS track on an HDR source therefore skipped the SDR alternate and returned adaptation_unavailable. Co-authored-by: Quick --- internal/api/handlers/playback_v3.go | 20 +++++++++++++++++--- internal/api/handlers/playback_v3_test.go | 2 +- 2 files changed, 18 insertions(+), 4 deletions(-) diff --git a/internal/api/handlers/playback_v3.go b/internal/api/handlers/playback_v3.go index 301782ca..a26acb81 100644 --- a/internal/api/handlers/playback_v3.go +++ b/internal/api/handlers/playback_v3.go @@ -2360,15 +2360,29 @@ func shouldTryAlternateFileV3(qualityPreference string) bool { } const ( - terminalNoAlternateVersionV3 = "no_alternate_version" - terminalHDRTranscodeUnsupportedV3 = "hdr_transcode_unsupported" + terminalNoAlternateVersionV3 = "no_alternate_version" + terminalHDRTranscodeUnsupportedV3 = "hdr_transcode_unsupported" + terminalSubtitleConversionUnsupportedV3 = "subtitle_conversion_unsupported" ) +// terminalAllowsAlternateFileV3 reports whether a planner terminal should +// trigger another media-file attempt before the response is finalized. +// +// subtitle_conversion_unsupported is included because a burn-in-only +// adaptation can rename an HDR or 4K blocker to that reason (see +// planVideoTranscodeV3's subtitleForcedAdaptation path). The underlying +// incompatibility is still version-shaped: an SDR / lower-resolution +// alternate may burn the same subtitle successfully. func terminalAllowsAlternateFileV3(terminal *playback.TerminalV3) bool { if terminal == nil { return false } - return terminal.Reason == terminalNoAlternateVersionV3 || terminal.Reason == terminalHDRTranscodeUnsupportedV3 + switch terminal.Reason { + case terminalNoAlternateVersionV3, terminalHDRTranscodeUnsupportedV3, terminalSubtitleConversionUnsupportedV3: + return true + default: + return false + } } func replanAllowsAlternateFileV3(operation playback.ReplanOperationV3, qualityPreference string) bool { diff --git a/internal/api/handlers/playback_v3_test.go b/internal/api/handlers/playback_v3_test.go index f8c9c8c2..ddae6f7f 100644 --- a/internal/api/handlers/playback_v3_test.go +++ b/internal/api/handlers/playback_v3_test.go @@ -117,7 +117,7 @@ func TestShouldTryAlternateFileV3PinsOriginalQuality(t *testing.T) { } func TestTerminalAllowsAlternateFileV3IncludesHDRIncompatibility(t *testing.T) { - for _, reason := range []string{"no_alternate_version", "hdr_transcode_unsupported"} { + for _, reason := range []string{"no_alternate_version", "hdr_transcode_unsupported", "subtitle_conversion_unsupported"} { if !terminalAllowsAlternateFileV3(&playback.TerminalV3{Reason: reason}) { t.Fatalf("terminal reason %q should permit alternate selection", reason) }