From e0f9ebd0b84ed438e6b11966867c07d29a07d78c Mon Sep 17 00:00:00 2001 From: Scott Date: Sat, 31 Oct 2015 17:40:57 +0000 Subject: Make Process Priority a real-time setting. Not per encode instance. --- .../Model/HBConfiguration.cs | 5 ----- .../Factories/HBConfigurationFactory.cs | 1 - win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs | 23 -------------------- win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 23 ++++++++++++++++++++ win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs | 25 +++++++++++++++++++++- 5 files changed, 47 insertions(+), 30 deletions(-) (limited to 'win') diff --git a/win/CS/HandBrake.ApplicationServices/Model/HBConfiguration.cs b/win/CS/HandBrake.ApplicationServices/Model/HBConfiguration.cs index ecb82ba85..7cce56bb5 100644 --- a/win/CS/HandBrake.ApplicationServices/Model/HBConfiguration.cs +++ b/win/CS/HandBrake.ApplicationServices/Model/HBConfiguration.cs @@ -49,11 +49,6 @@ namespace HandBrake.ApplicationServices.Model /// public int MinScanDuration { get; set; } - /// - /// Gets or sets the process priority. - /// - public string ProcessPriority { get; set; } - /// /// Gets or sets a value indicating whether save log to copy directory. /// diff --git a/win/CS/HandBrakeWPF/Factories/HBConfigurationFactory.cs b/win/CS/HandBrakeWPF/Factories/HBConfigurationFactory.cs index c0ba00633..c500ef7b1 100644 --- a/win/CS/HandBrakeWPF/Factories/HBConfigurationFactory.cs +++ b/win/CS/HandBrakeWPF/Factories/HBConfigurationFactory.cs @@ -42,7 +42,6 @@ namespace HandBrakeWPF.Factories PreviewScanCount = UserSettingService.GetUserSetting(UserSettingConstants.PreviewScanCount), Verbosity = UserSettingService.GetUserSetting(UserSettingConstants.Verbosity), MinScanDuration = UserSettingService.GetUserSetting(UserSettingConstants.MinScanDuration), - ProcessPriority = UserSettingService.GetUserSetting(UserSettingConstants.ProcessPriority), SaveLogToCopyDirectory = UserSettingService.GetUserSetting(UserSettingConstants.SaveLogToCopyDirectory), SaveLogWithVideo = UserSettingService.GetUserSetting(UserSettingConstants.SaveLogWithVideo), SaveLogCopyDirectory = UserSettingService.GetUserSetting(UserSettingConstants.SaveLogCopyDirectory), diff --git a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs index 111c91c6e..4bf64e5e1 100644 --- a/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs +++ b/win/CS/HandBrakeWPF/Services/Encode/LibEncode.cs @@ -91,29 +91,6 @@ namespace HandBrakeWPF.Services.Encode // Fire the Encode Started Event this.InvokeEncodeStarted(System.EventArgs.Empty); - - // Set the Process Priority - switch (configuration.ProcessPriority) - { - case "Realtime": - Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime; - break; - case "High": - Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High; - break; - case "Above Normal": - Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.AboveNormal; - break; - case "Normal": - Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal; - break; - case "Low": - Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Idle; - break; - default: - Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.BelowNormal; - break; - } } catch (Exception exc) { diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 8ecb46ae2..69d38f159 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -198,6 +198,29 @@ namespace HandBrakeWPF.ViewModels this.Presets = this.presetService.Presets; this.Drives = new BindingList(); + // Set Process Priority + switch (this.userSettingService.GetUserSetting(UserSettingConstants.ProcessPriority)) + { + case "Realtime": + Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime; + break; + case "High": + Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High; + break; + case "Above Normal": + Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.AboveNormal; + break; + case "Normal": + Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal; + break; + case "Low": + Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Idle; + break; + default: + Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.BelowNormal; + break; + } + HandBrakeInstanceManager.Init(); } diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs index 4d7ea3a80..3e37a8a85 100644 --- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs @@ -633,7 +633,30 @@ namespace HandBrakeWPF.ViewModels set { this.selectedPriority = value; - this.NotifyOfPropertyChange("SelectedPriority"); + this.NotifyOfPropertyChange(); + + // Set the Process Priority + switch (value) + { + case "Realtime": + Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.RealTime; + break; + case "High": + Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.High; + break; + case "Above Normal": + Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.AboveNormal; + break; + case "Normal": + Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Normal; + break; + case "Low": + Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.Idle; + break; + default: + Process.GetCurrentProcess().PriorityClass = ProcessPriorityClass.BelowNormal; + break; + } } } #endregion -- cgit v1.2.3