diff options
| author | Anthony Lavado <anthonylavado@users.noreply.github.com> | 2019-09-02 02:07:19 -0400 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2019-09-02 02:07:19 -0400 |
| commit | cb393c215a2ea75f61d0e3e798c6a4a596d720c2 (patch) | |
| tree | 1eb9586e139de7af8cc906ca4aa758e5106cb35d /Emby.Server.Implementations | |
| parent | c4eac8b3c6257e4a2aab2fa93d877fbcff8fee51 (diff) | |
| parent | e4f893a0eb955d43e7ef4c99bef8d4bfeb61a771 (diff) | |
Merge pull request #1686 from Bond-009/warn7
More warning fixes
Diffstat (limited to 'Emby.Server.Implementations')
5 files changed, 141 insertions, 70 deletions
diff --git a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs index fb4ffd74b..1514402d6 100644 --- a/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs +++ b/Emby.Server.Implementations/Activity/ActivityLogEntryPoint.cs @@ -96,7 +96,10 @@ namespace Emby.Server.Implementations.Activity { CreateLogEntry(new ActivityLogEntry { - Name = string.Format(_localization.GetLocalizedString("CameraImageUploadedFrom"), e.Argument.Device.Name), + Name = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("CameraImageUploadedFrom"), + e.Argument.Device.Name), Type = NotificationType.CameraImageUploaded.ToString() }); } @@ -105,7 +108,10 @@ namespace Emby.Server.Implementations.Activity { CreateLogEntry(new ActivityLogEntry { - Name = string.Format(_localization.GetLocalizedString("UserLockedOutWithName"), e.Argument.Name), + Name = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("UserLockedOutWithName"), + e.Argument.Name), Type = NotificationType.UserLockedOut.ToString(), UserId = e.Argument.Id }); @@ -115,7 +121,11 @@ namespace Emby.Server.Implementations.Activity { CreateLogEntry(new ActivityLogEntry { - Name = string.Format(_localization.GetLocalizedString("SubtitleDownloadFailureFromForItem"), e.Provider, Notifications.Notifications.GetItemName(e.Item)), + Name = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("SubtitleDownloadFailureFromForItem"), + e.Provider, + Notifications.Notifications.GetItemName(e.Item)), Type = "SubtitleDownloadFailure", ItemId = e.Item.Id.ToString("N", CultureInfo.InvariantCulture), ShortOverview = e.Exception.Message @@ -178,7 +188,12 @@ namespace Emby.Server.Implementations.Activity CreateLogEntry(new ActivityLogEntry { - Name = string.Format(_localization.GetLocalizedString("UserStartedPlayingItemWithValues"), user.Name, GetItemName(item), e.DeviceName), + Name = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("UserStartedPlayingItemWithValues"), + user.Name, + GetItemName(item), + e.DeviceName), Type = GetPlaybackNotificationType(item.MediaType), UserId = user.Id }); @@ -193,7 +208,7 @@ namespace Emby.Server.Implementations.Activity name = item.SeriesName + " - " + name; } - if (item.Artists != null && item.Artists.Length > 0) + if (item.Artists != null && item.Artists.Count > 0) { name = item.Artists[0] + " - " + name; } @@ -238,21 +253,31 @@ namespace Emby.Server.Implementations.Activity if (string.IsNullOrEmpty(session.UserName)) { - name = string.Format(_localization.GetLocalizedString("DeviceOfflineWithName"), session.DeviceName); + name = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("DeviceOfflineWithName"), + session.DeviceName); // Causing too much spam for now return; } else { - name = string.Format(_localization.GetLocalizedString("UserOfflineFromDevice"), session.UserName, session.DeviceName); + name = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("UserOfflineFromDevice"), + session.UserName, + session.DeviceName); } CreateLogEntry(new ActivityLogEntry { Name = name, Type = "SessionEnded", - ShortOverview = string.Format(_localization.GetLocalizedString("LabelIpAddressValue"), session.RemoteEndPoint), + ShortOverview = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("LabelIpAddressValue"), + session.RemoteEndPoint), UserId = session.UserId }); } @@ -263,9 +288,15 @@ namespace Emby.Server.Implementations.Activity CreateLogEntry(new ActivityLogEntry { - Name = string.Format(_localization.GetLocalizedString("AuthenticationSucceededWithUserName"), user.Name), + Name = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("AuthenticationSucceededWithUserName"), + user.Name), Type = "AuthenticationSucceeded", - ShortOverview = string.Format(_localization.GetLocalizedString("LabelIpAddressValue"), e.Argument.SessionInfo.RemoteEndPoint), + ShortOverview = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("LabelIpAddressValue"), + e.Argument.SessionInfo.RemoteEndPoint), UserId = user.Id }); } @@ -274,9 +305,15 @@ namespace Emby.Server.Implementations.Activity { CreateLogEntry(new ActivityLogEntry { - Name = string.Format(_localization.GetLocalizedString("FailedLoginAttemptWithUserName"), e.Argument.Username), + Name = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("FailedLoginAttemptWithUserName"), + e.Argument.Username), Type = "AuthenticationFailed", - ShortOverview = string.Format(_localization.GetLocalizedString("LabelIpAddressValue"), e.Argument.RemoteEndPoint), + ShortOverview = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("LabelIpAddressValue"), + e.Argument.RemoteEndPoint), Severity = LogLevel.Error }); } @@ -285,7 +322,10 @@ namespace Emby.Server.Implementations.Activity { CreateLogEntry(new ActivityLogEntry { - Name = string.Format(_localization.GetLocalizedString("UserPolicyUpdatedWithName"), e.Argument.Name), + Name = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("UserPolicyUpdatedWithName"), + e.Argument.Name), Type = "UserPolicyUpdated", UserId = e.Argument.Id }); @@ -295,7 +335,10 @@ namespace Emby.Server.Implementations.Activity { CreateLogEntry(new ActivityLogEntry { - Name = string.Format(_localization.GetLocalizedString("UserDeletedWithName"), e.Argument.Name), + Name = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("UserDeletedWithName"), + e.Argument.Name), Type = "UserDeleted" }); } @@ -304,7 +347,10 @@ namespace Emby.Server.Implementations.Activity { CreateLogEntry(new ActivityLogEntry { - Name = string.Format(_localization.GetLocalizedString("UserPasswordChangedWithName"), e.Argument.Name), + Name = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("UserPasswordChangedWithName"), + e.Argument.Name), Type = "UserPasswordChanged", UserId = e.Argument.Id }); @@ -314,7 +360,10 @@ namespace Emby.Server.Implementations.Activity { CreateLogEntry(new ActivityLogEntry { - Name = string.Format(_localization.GetLocalizedString("UserCreatedWithName"), e.Argument.Name), + Name = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("UserCreatedWithName"), + e.Argument.Name), Type = "UserCreated", UserId = e.Argument.Id }); @@ -327,21 +376,31 @@ namespace Emby.Server.Implementations.Activity if (string.IsNullOrEmpty(session.UserName)) { - name = string.Format(_localization.GetLocalizedString("DeviceOnlineWithName"), session.DeviceName); + name = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("DeviceOnlineWithName"), + session.DeviceName); // Causing too much spam for now return; } else { - name = string.Format(_localization.GetLocalizedString("UserOnlineFromDevice"), session.UserName, session.DeviceName); + name = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("UserOnlineFromDevice"), + session.UserName, + session.DeviceName); } CreateLogEntry(new ActivityLogEntry { Name = name, Type = "SessionStarted", - ShortOverview = string.Format(_localization.GetLocalizedString("LabelIpAddressValue"), session.RemoteEndPoint), + ShortOverview = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("LabelIpAddressValue"), + session.RemoteEndPoint), UserId = session.UserId }); } @@ -350,9 +409,15 @@ namespace Emby.Server.Implementations.Activity { CreateLogEntry(new ActivityLogEntry { - Name = string.Format(_localization.GetLocalizedString("PluginUpdatedWithName"), e.Argument.Item1.Name), + Name = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("PluginUpdatedWithName"), + e.Argument.Item1.Name), Type = NotificationType.PluginUpdateInstalled.ToString(), - ShortOverview = string.Format(_localization.GetLocalizedString("VersionNumber"), e.Argument.Item2.versionStr), + ShortOverview = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("VersionNumber"), + e.Argument.Item2.versionStr), Overview = e.Argument.Item2.description }); } @@ -361,7 +426,10 @@ namespace Emby.Server.Implementations.Activity { CreateLogEntry(new ActivityLogEntry { - Name = string.Format(_localization.GetLocalizedString("PluginUninstalledWithName"), e.Argument.Name), + Name = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("PluginUninstalledWithName"), + e.Argument.Name), Type = NotificationType.PluginUninstalled.ToString() }); } @@ -370,9 +438,15 @@ namespace Emby.Server.Implementations.Activity { CreateLogEntry(new ActivityLogEntry { - Name = string.Format(_localization.GetLocalizedString("PluginInstalledWithName"), e.Argument.name), + Name = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("PluginInstalledWithName"), + e.Argument.name), Type = NotificationType.PluginInstalled.ToString(), - ShortOverview = string.Format(_localization.GetLocalizedString("VersionNumber"), e.Argument.versionStr) + ShortOverview = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("VersionNumber"), + e.Argument.versionStr) }); } @@ -382,9 +456,15 @@ namespace Emby.Server.Implementations.Activity CreateLogEntry(new ActivityLogEntry { - Name = string.Format(_localization.GetLocalizedString("NameInstallFailed"), installationInfo.Name), + Name = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("NameInstallFailed"), + installationInfo.Name), Type = NotificationType.InstallationFailed.ToString(), - ShortOverview = string.Format(_localization.GetLocalizedString("VersionNumber"), installationInfo.Version), + ShortOverview = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("VersionNumber"), + installationInfo.Version), Overview = e.Exception.Message }); } @@ -401,7 +481,10 @@ namespace Emby.Server.Implementations.Activity } var time = result.EndTimeUtc - result.StartTimeUtc; - var runningTime = string.Format(_localization.GetLocalizedString("LabelRunningTimeValue"), ToUserFriendlyString(time)); + var runningTime = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("LabelRunningTimeValue"), + ToUserFriendlyString(time)); if (result.Status == TaskCompletionStatus.Failed) { @@ -419,7 +502,10 @@ namespace Emby.Server.Implementations.Activity CreateLogEntry(new ActivityLogEntry { - Name = string.Format(_localization.GetLocalizedString("ScheduledTaskFailedWithName"), task.Name), + Name = string.Format( + CultureInfo.InvariantCulture, + _localization.GetLocalizedString("ScheduledTaskFailedWithName"), + task.Name), Type = NotificationType.TaskFailed.ToString(), Overview = string.Join(Environment.NewLine, vals), ShortOverview = runningTime, @@ -534,8 +620,11 @@ namespace Emby.Server.Implementations.Activity /// <param name="description">The name of this item (singular form)</param> private static string CreateValueString(int value, string description) { - return string.Format("{0:#,##0} {1}", - value, value == 1 ? description : string.Format("{0}s", description)); + return string.Format( + CultureInfo.InvariantCulture, + "{0:#,##0} {1}", + value, + value == 1 ? description : string.Format(CultureInfo.InvariantCulture, "{0}s", description)); } } } diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index 9d983307f..c3789eef2 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -979,7 +979,7 @@ namespace Emby.Server.Implementations.Data } string artists = null; - if (item is IHasArtist hasArtists && hasArtists.Artists.Length > 0) + if (item is IHasArtist hasArtists && hasArtists.Artists.Count > 0) { artists = string.Join("|", hasArtists.Artists); } @@ -987,7 +987,7 @@ namespace Emby.Server.Implementations.Data string albumArtists = null; if (item is IHasAlbumArtist hasAlbumArtists - && hasAlbumArtists.AlbumArtists.Length > 0) + && hasAlbumArtists.AlbumArtists.Count > 0) { albumArtists = string.Join("|", hasAlbumArtists.AlbumArtists); } @@ -5731,7 +5731,7 @@ where AncestorIdText not null and ItemValues.Value not null and ItemValues.Type { if (isSubsequentRow) { - insertText.Append(","); + insertText.Append(','); } insertText.AppendFormat("(@ItemId, @Name{0}, @Role{0}, @PersonType{0}, @SortOrder{0}, @ListOrder{0})", i.ToString(CultureInfo.InvariantCulture)); diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index 97ddfff53..6da102618 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -886,8 +886,7 @@ namespace Emby.Server.Implementations.Dto //} } - var hasArtist = item as IHasArtist; - if (hasArtist != null) + if (item is IHasArtist hasArtist) { dto.Artists = hasArtist.Artists; diff --git a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs index 75efa7ec8..3cc0541e7 100644 --- a/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs +++ b/Emby.Server.Implementations/LiveTv/EmbyTV/EncodedRecorder.cs @@ -87,8 +87,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV CreateNoWindow = true, UseShellExecute = false, - // Must consume both stdout and stderr or deadlocks may occur - //RedirectStandardOutput = true, RedirectStandardError = true, RedirectStandardInput = true, @@ -120,9 +118,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV cancellationToken.Register(Stop); - // MUST read both stdout and stderr asynchronously or a deadlock may occurr - //process.BeginOutputReadLine(); - onStarted(); // Important - don't await the log task or we won't be able to kill ffmpeg when the user stops playback @@ -138,11 +133,12 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV string videoArgs; if (EncodeVideo(mediaSource)) { - var maxBitrate = 25000000; + const int MaxBitrate = 25000000; videoArgs = string.Format( - "-codec:v:0 libx264 -force_key_frames \"expr:gte(t,n_forced*5)\" {0} -pix_fmt yuv420p -preset superfast -crf 23 -b:v {1} -maxrate {1} -bufsize ({1}*2) -vsync -1 -profile:v high -level 41", - GetOutputSizeParam(), - maxBitrate.ToString(CultureInfo.InvariantCulture)); + CultureInfo.InvariantCulture, + "-codec:v:0 libx264 -force_key_frames \"expr:gte(t,n_forced*5)\" {0} -pix_fmt yuv420p -preset superfast -crf 23 -b:v {1} -maxrate {1} -bufsize ({1}*2) -vsync -1 -profile:v high -level 41", + GetOutputSizeParam(), + MaxBitrate); } else { @@ -151,18 +147,17 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV videoArgs += " -fflags +genpts"; - var durationParam = " -t " + _mediaEncoder.GetTimeParameter(duration.Ticks); - durationParam = string.Empty; - var flags = new List<string>(); if (mediaSource.IgnoreDts) { flags.Add("+igndts"); } + if (mediaSource.IgnoreIndex) { flags.Add("+ignidx"); } + if (mediaSource.GenPtsInput) { flags.Add("+genpts"); @@ -172,11 +167,9 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV if (flags.Count > 0) { - inputModifier += " -fflags " + string.Join("", flags.ToArray()); + inputModifier += " -fflags " + string.Join(string.Empty, flags); } - var videoStream = mediaSource.VideoStream; - if (mediaSource.ReadAtNativeFramerate) { inputModifier += " -re"; @@ -200,13 +193,14 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV var outputParam = string.Empty; - var commandLineArgs = string.Format("-i \"{0}\"{5} {2} -map_metadata -1 -threads 0 {3}{4}{6} -y \"{1}\"", + var commandLineArgs = string.Format( + CultureInfo.InvariantCulture, + "-i \"{0}\" {2} -map_metadata -1 -threads 0 {3}{4}{5} -y \"{1}\"", inputTempFile, targetFile, videoArgs, GetAudioArgs(mediaSource), subtitleArgs, - durationParam, outputParam); return inputModifier + " " + commandLineArgs; @@ -257,7 +251,6 @@ namespace Emby.Server.Implementations.LiveTv.EmbyTV { _logger.LogInformation("Stopping ffmpeg recording process for {path}", _targetPath); - //process.Kill(); _process.StandardInput.WriteLine("q"); } catch (Exception ex) diff --git a/Emby.Server.Implementations/Sorting/ArtistComparer.cs b/Emby.Server.Implementations/Sorting/ArtistComparer.cs index 9d5befc9a..756d3c5b6 100644 --- a/Emby.Server.Implementations/Sorting/ArtistComparer.cs +++ b/Emby.Server.Implementations/Sorting/ArtistComparer.cs @@ -7,16 +7,14 @@ using MediaBrowser.Model.Querying; namespace Emby.Server.Implementations.Sorting { /// <summary> - /// Class ArtistComparer + /// Class ArtistComparer. /// </summary> public class ArtistComparer : IBaseItemComparer { - /// <summary> - /// Compares the specified x. - /// </summary> - /// <param name="x">The x.</param> - /// <param name="y">The y.</param> - /// <returns>System.Int32.</returns> + /// <inheritdoc /> + public string Name => ItemSortBy.Artist; + + /// <inheritdoc /> public int Compare(BaseItem x, BaseItem y) { return string.Compare(GetValue(x), GetValue(y), StringComparison.CurrentCultureIgnoreCase); @@ -29,20 +27,12 @@ namespace Emby.Server.Implementations.Sorting /// <returns>System.String.</returns> private static string GetValue(BaseItem x) { - var audio = x as Audio; - - if (audio == null) + if (!(x is Audio audio)) { return string.Empty; } - return audio.Artists.Length == 0 ? null : audio.Artists[0]; + return audio.Artists.Count == 0 ? null : audio.Artists[0]; } - - /// <summary> - /// Gets the name. - /// </summary> - /// <value>The name.</value> - public string Name => ItemSortBy.Artist; } } |
