mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-06-14 03:30:25 +01:00
Only reselect audio streams when user preference is respected (#13832)
Some checks are pending
CodeQL / Analyze (csharp) (push) Waiting to run
OpenAPI / OpenAPI - HEAD (push) Waiting to run
OpenAPI / OpenAPI - BASE (push) Waiting to run
OpenAPI / OpenAPI - Difference (push) Blocked by required conditions
OpenAPI / OpenAPI - Publish Unstable Spec (push) Blocked by required conditions
OpenAPI / OpenAPI - Publish Stable Spec (push) Blocked by required conditions
Tests / run-tests (macos-latest) (push) Waiting to run
Tests / run-tests (ubuntu-latest) (push) Waiting to run
Tests / run-tests (windows-latest) (push) Waiting to run
Project Automation / Project board (push) Waiting to run
Merge Conflict Labeler / Labeling (push) Waiting to run
Some checks are pending
CodeQL / Analyze (csharp) (push) Waiting to run
OpenAPI / OpenAPI - HEAD (push) Waiting to run
OpenAPI / OpenAPI - BASE (push) Waiting to run
OpenAPI / OpenAPI - Difference (push) Blocked by required conditions
OpenAPI / OpenAPI - Publish Unstable Spec (push) Blocked by required conditions
OpenAPI / OpenAPI - Publish Stable Spec (push) Blocked by required conditions
Tests / run-tests (macos-latest) (push) Waiting to run
Tests / run-tests (ubuntu-latest) (push) Waiting to run
Tests / run-tests (windows-latest) (push) Waiting to run
Project Automation / Project board (push) Waiting to run
Merge Conflict Labeler / Labeling (push) Waiting to run
This commit is contained in:
@@ -665,15 +665,39 @@ namespace MediaBrowser.Model.Dlna
|
||||
|
||||
// Collect candidate audio streams
|
||||
ICollection<MediaStream> candidateAudioStreams = audioStream is null ? [] : [audioStream];
|
||||
if (!options.AudioStreamIndex.HasValue || options.AudioStreamIndex < 0)
|
||||
// When the index is explicitly required by client or the default is specified by user, don't do any stream reselection.
|
||||
if (!item.DefaultAudioIndexSource.HasFlag(AudioIndexSource.User) && (options.AudioStreamIndex is null or < 0))
|
||||
{
|
||||
if (audioStream?.IsDefault == true)
|
||||
// When user has no preferences allow stream selection on all streams.
|
||||
if (item.DefaultAudioIndexSource == AudioIndexSource.None && audioStream is not null)
|
||||
{
|
||||
candidateAudioStreams = item.MediaStreams.Where(stream => stream.Type == MediaStreamType.Audio && stream.IsDefault).ToArray();
|
||||
candidateAudioStreams = item.MediaStreams.Where(stream => stream.Type == MediaStreamType.Audio).ToArray();
|
||||
if (audioStream.IsDefault)
|
||||
{
|
||||
// If default is picked, only allow selection within default streams.
|
||||
candidateAudioStreams = candidateAudioStreams.Where(stream => stream.IsDefault).ToArray();
|
||||
}
|
||||
}
|
||||
else
|
||||
|
||||
if (item.DefaultAudioIndexSource.HasFlag(AudioIndexSource.Language))
|
||||
{
|
||||
// If user has language preference, only allow stream selection within the same language.
|
||||
candidateAudioStreams = item.MediaStreams.Where(stream => stream.Type == MediaStreamType.Audio && stream.Language == audioStream?.Language).ToArray();
|
||||
if (item.DefaultAudioIndexSource.HasFlag(AudioIndexSource.Default))
|
||||
{
|
||||
var defaultStreamsInPreferredLanguage = candidateAudioStreams.Where(stream => stream.IsDefault).ToArray();
|
||||
|
||||
// If the user also prefers default streams, try limit selection within default tracks in the same language.
|
||||
// If there is no default stream in the preferred language, allow selection on all default streams to match the "Play default audio track regardless of language" setting.
|
||||
candidateAudioStreams = defaultStreamsInPreferredLanguage.Length > 0
|
||||
? defaultStreamsInPreferredLanguage
|
||||
: item.MediaStreams.Where(stream => stream.Type == MediaStreamType.Audio && stream.IsDefault).ToArray();
|
||||
}
|
||||
}
|
||||
else if (item.DefaultAudioIndexSource.HasFlag(AudioIndexSource.Default))
|
||||
{
|
||||
// If user prefers default streams, only allow stream selection on default streams.
|
||||
candidateAudioStreams = item.MediaStreams.Where(stream => stream.Type == MediaStreamType.Audio && stream.IsDefault).ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user