From d8ec3a5470fe602fab356c37720d38190aa713ef Mon Sep 17 00:00:00 2001 From: Bond_009 Date: Wed, 1 Mar 2023 18:57:23 +0100 Subject: Reduce usage of GetAwaiter().GetResult() --- MediaBrowser.Model/Dlna/StreamBuilder.cs | 23 +++++++---------------- 1 file changed, 7 insertions(+), 16 deletions(-) (limited to 'MediaBrowser.Model') diff --git a/MediaBrowser.Model/Dlna/StreamBuilder.cs b/MediaBrowser.Model/Dlna/StreamBuilder.cs index 6f99bbc13..84c8c012c 100644 --- a/MediaBrowser.Model/Dlna/StreamBuilder.cs +++ b/MediaBrowser.Model/Dlna/StreamBuilder.cs @@ -44,32 +44,24 @@ namespace MediaBrowser.Model.Dlna { ValidateMediaOptions(options, false); - var mediaSources = new List(); + var streams = new List(); foreach (var mediaSource in options.MediaSources) { - if (string.IsNullOrEmpty(options.MediaSourceId) - || string.Equals(mediaSource.Id, options.MediaSourceId, StringComparison.OrdinalIgnoreCase)) + if (!(string.IsNullOrEmpty(options.MediaSourceId) + || string.Equals(mediaSource.Id, options.MediaSourceId, StringComparison.OrdinalIgnoreCase))) { - mediaSources.Add(mediaSource); + continue; } - } - var streams = new List(); - foreach (var mediaSourceInfo in mediaSources) - { - StreamInfo? streamInfo = GetOptimalAudioStream(mediaSourceInfo, options); + StreamInfo? streamInfo = GetOptimalAudioStream(mediaSource, options); if (streamInfo is not null) { + streamInfo.DeviceId = options.DeviceId; + streamInfo.DeviceProfileId = options.Profile.Id; streams.Add(streamInfo); } } - foreach (var stream in streams) - { - stream.DeviceId = options.DeviceId; - stream.DeviceProfileId = options.Profile.Id; - } - return GetOptimalStream(streams, options.GetMaxBitrate(true) ?? 0); } @@ -399,7 +391,6 @@ namespace MediaBrowser.Model.Dlna return (null, null, GetTranscodeReasonsFromDirectPlayProfile(item, null, audioStream, options.Profile.DirectPlayProfiles)); } - var playMethods = new List(); TranscodeReason transcodeReasons = 0; // The profile describes what the device supports -- cgit v1.2.3