Fall back to first audio track when none preferred

Auto-selection still prefers Japanese/Chinese/undefined audio, but
if a file has none of those (e.g. only English), the first audio
track is pre-checked instead of leaving no audio track selected.
This commit is contained in:
2026-07-08 10:53:48 +02:00
parent c7c125d40b
commit a5f221f688
2 changed files with 10 additions and 6 deletions
+2 -2
View File
@@ -9,8 +9,8 @@
<ImplicitUsings>enable</ImplicitUsings> <ImplicitUsings>enable</ImplicitUsings>
<AssemblyName>Futonizer</AssemblyName> <AssemblyName>Futonizer</AssemblyName>
<RootNamespace>Futonizer</RootNamespace> <RootNamespace>Futonizer</RootNamespace>
<Version>1.0.6</Version> <Version>1.0.7</Version>
<FileVersion>1.0.6.0</FileVersion> <FileVersion>1.0.7.0</FileVersion>
<ApplicationIcon>Assets\app.ico</ApplicationIcon> <ApplicationIcon>Assets\app.ico</ApplicationIcon>
</PropertyGroup> </PropertyGroup>
+8 -4
View File
@@ -93,9 +93,12 @@ public class MkvService
/// <summary> /// <summary>
/// Builds the list of <see cref="TrackItem"/> objects for a file. Video /// Builds the list of <see cref="TrackItem"/> objects for a file. Video
/// tracks are always pre-checked. Exactly one audio track is pre-checked: /// tracks are always pre-checked. Exactly one audio track is always
/// among Japanese/Chinese/undefined-language tracks, a stereo (2-channel) /// pre-checked: among Japanese/Chinese/undefined-language tracks, a
/// track is preferred, otherwise the first matching track in file order. /// stereo (2-channel) track is preferred, otherwise the first matching
/// track in file order. If no such track exists (e.g. only English
/// audio), the very first audio track in the file is pre-checked instead,
/// so a file is never left with no audio track selected.
/// Subtitle tracks are never pre-checked — the user picks one via the /// Subtitle tracks are never pre-checked — the user picks one via the
/// track table, and the choice propagates to other queued files. /// track table, and the choice propagates to other queued files.
/// </summary> /// </summary>
@@ -108,7 +111,8 @@ public class MkvService
.ToList(); .ToList();
MkvTrack? preferredAudio = eligibleAudio.FirstOrDefault(t => t.Properties?.AudioChannels == 2) MkvTrack? preferredAudio = eligibleAudio.FirstOrDefault(t => t.Properties?.AudioChannels == 2)
?? eligibleAudio.FirstOrDefault(); ?? eligibleAudio.FirstOrDefault()
?? audioTracks.FirstOrDefault();
var items = info.Tracks.Select(t => var items = info.Tracks.Select(t =>
{ {