diff options
Diffstat (limited to 'win/CS/HandBrakeWPF')
-rw-r--r-- | win/CS/HandBrakeWPF/App.xaml.cs | 29 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Factories/HBConfigurationFactory.cs | 11 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Instance/HandBrakeInstanceManager.cs | 48 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Instance/RemoteInstance.cs | 2 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Properties/Resources.Designer.cs | 11 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Properties/Resources.resx | 5 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/Services/Scan/LibScan.cs | 2 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs | 4 | ||||
-rw-r--r-- | win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs | 2 |
9 files changed, 85 insertions, 29 deletions
diff --git a/win/CS/HandBrakeWPF/App.xaml.cs b/win/CS/HandBrakeWPF/App.xaml.cs index 7aa538137..c784eb7a5 100644 --- a/win/CS/HandBrakeWPF/App.xaml.cs +++ b/win/CS/HandBrakeWPF/App.xaml.cs @@ -20,7 +20,10 @@ namespace HandBrakeWPF using Caliburn.Micro;
+ using HandBrake.Interop.Interop;
+
using HandBrakeWPF.Helpers;
+ using HandBrakeWPF.Instance;
using HandBrakeWPF.Model;
using HandBrakeWPF.Services.Interfaces;
using HandBrakeWPF.Startup;
@@ -119,6 +122,28 @@ namespace HandBrakeWPF }
}
+
+ // NO-Hardware Mode
+ bool noHardware = e.Args.Any(f => f.Equals("--no-hardware"));
+
+ // Initialise the Engine
+ HandBrakeWPF.Helpers.LogManager.Init();
+
+ try
+ {
+ HandBrakeInstanceManager.Init(noHardware);
+ }
+ catch (Exception exception)
+ {
+ if (!noHardware)
+ {
+ MessageBox.Show(HandBrakeWPF.Properties.Resources.Startup_InitFailed, HandBrakeWPF.Properties.Resources.Error, MessageBoxButton.OK, MessageBoxImage.Error);
+ }
+
+ throw exception;
+ }
+
+ // Initialise the GUI
base.OnStartup(e);
// If we have a file dropped on the icon, try scanning it.
@@ -144,7 +169,7 @@ namespace HandBrakeWPF Caliburn.Micro.Execute.OnUIThreadAsync(() => {
if (e.ExceptionObject.GetType() == typeof(FileNotFoundException))
{
- GeneralApplicationException exception = new GeneralApplicationException("A file appears to be missing.", "Try re-installing Microsoft .NET Framework 4.0", (Exception)e.ExceptionObject);
+ GeneralApplicationException exception = new GeneralApplicationException("A file appears to be missing.", "Try re-installing Microsoft .NET Framework 4.7.1", (Exception)e.ExceptionObject);
this.ShowError(exception);
}
else
@@ -168,7 +193,7 @@ namespace HandBrakeWPF {
if (e.Exception.GetType() == typeof(FileNotFoundException))
{
- GeneralApplicationException exception = new GeneralApplicationException("A file appears to be missing.", "Try re-installing Microsoft .NET Framework 4.0", e.Exception);
+ GeneralApplicationException exception = new GeneralApplicationException("A file appears to be missing.", "Try re-installing Microsoft .NET Framework 4.7.1", e.Exception);
this.ShowError(exception);
}
else if (e.Exception.GetType() == typeof(GeneralApplicationException))
diff --git a/win/CS/HandBrakeWPF/Factories/HBConfigurationFactory.cs b/win/CS/HandBrakeWPF/Factories/HBConfigurationFactory.cs index f4e0b9ee7..b2aba62ae 100644 --- a/win/CS/HandBrakeWPF/Factories/HBConfigurationFactory.cs +++ b/win/CS/HandBrakeWPF/Factories/HBConfigurationFactory.cs @@ -36,8 +36,6 @@ namespace HandBrakeWPF.Factories HBConfiguration config = new HBConfiguration
{
IsDvdNavDisabled = UserSettingService.GetUserSetting<bool>(UserSettingConstants.DisableLibDvdNav),
- EnableQuickSyncDecoding = UserSettingService.GetUserSetting<bool>(UserSettingConstants.EnableQuickSyncDecoding),
- UseQSVDecodeForNonQSVEnc = UserSettingService.GetUserSetting<bool>(UserSettingConstants.UseQSVDecodeForNonQSVEnc),
ScalingMode = UserSettingService.GetUserSetting<VideoScaler>(UserSettingConstants.ScalingMode, typeof(int)),
PreviewScanCount = UserSettingService.GetUserSetting<int>(UserSettingConstants.PreviewScanCount, typeof(int)),
Verbosity = UserSettingService.GetUserSetting<int>(UserSettingConstants.Verbosity, typeof(int)),
@@ -46,8 +44,13 @@ namespace HandBrakeWPF.Factories SaveLogWithVideo = UserSettingService.GetUserSetting<bool>(UserSettingConstants.SaveLogWithVideo),
SaveLogCopyDirectory = UserSettingService.GetUserSetting<string>(UserSettingConstants.SaveLogCopyDirectory),
RemoteServiceEnabled = UserSettingService.GetUserSetting<bool>(UserSettingConstants.RemoteServiceEnabled),
- RemoteServicePort = UserSettingService.GetUserSetting<int>(UserSettingConstants.RemoteServicePort, typeof(int))
- };
+ RemoteServicePort = UserSettingService.GetUserSetting<int>(UserSettingConstants.RemoteServicePort, typeof(int)),
+ EnableVceEncoder = UserSettingService.GetUserSetting<bool>(UserSettingConstants.EnableVceEncoder),
+ EnableNvencEncoder = UserSettingService.GetUserSetting<bool>(UserSettingConstants.EnableNvencEncoder),
+ EnableQsvEncoder = UserSettingService.GetUserSetting<bool>(UserSettingConstants.EnableQuickSyncEncoding),
+ EnableQuickSyncDecoding = UserSettingService.GetUserSetting<bool>(UserSettingConstants.EnableQuickSyncDecoding),
+ UseQSVDecodeForNonQSVEnc = UserSettingService.GetUserSetting<bool>(UserSettingConstants.UseQSVDecodeForNonQSVEnc)
+ };
return config;
}
diff --git a/win/CS/HandBrakeWPF/Instance/HandBrakeInstanceManager.cs b/win/CS/HandBrakeWPF/Instance/HandBrakeInstanceManager.cs index d841dfab5..bfcf2ecd7 100644 --- a/win/CS/HandBrakeWPF/Instance/HandBrakeInstanceManager.cs +++ b/win/CS/HandBrakeWPF/Instance/HandBrakeInstanceManager.cs @@ -9,10 +9,15 @@ namespace HandBrakeWPF.Instance { + using System; + using System.Runtime.CompilerServices; + using HandBrake.Interop.Interop; using HandBrake.Interop.Interop.Interfaces; using HandBrake.Interop.Model; + using HandBrakeWPF.Factories; + /// <summary> /// The HandBrake Instance manager. /// Only supports scanning right now. @@ -22,20 +27,16 @@ namespace HandBrakeWPF.Instance private static IEncodeInstance encodeInstance; private static HandBrakeInstance scanInstance; private static HandBrakeInstance previewInstance; - - /// <summary> - /// Initializes static members of the <see cref="HandBrakeInstanceManager"/> class. - /// </summary> - static HandBrakeInstanceManager() - { - } + private static bool noHardware; /// <summary> /// The init. /// </summary> - public static void Init() + public static void Init(bool noHardwareMode) { - // Nothing to do. Triggers static constructor. + noHardware = noHardwareMode; + HandBrakeUtils.RegisterLogger(); + HandBrakeUtils.EnsureGlobalInit(noHardwareMode); } /// <summary> @@ -52,6 +53,11 @@ namespace HandBrakeWPF.Instance /// </returns> public static IEncodeInstance GetEncodeInstance(int verbosity, HBConfiguration configuration) { + if (!HandBrakeUtils.IsInitialised()) + { + throw new Exception("Please call Init before Using!"); + } + if (encodeInstance != null) { encodeInstance.Dispose(); @@ -68,8 +74,9 @@ namespace HandBrakeWPF.Instance { newInstance = new HandBrakeInstance(); } - - newInstance.Initialize(verbosity); + + newInstance.Initialize(verbosity, noHardware); + encodeInstance = newInstance; HandBrakeUtils.SetDvdNav(!configuration.IsDvdNavDisabled); @@ -83,11 +90,19 @@ namespace HandBrakeWPF.Instance /// <param name="verbosity"> /// The verbosity. /// </param> + /// <param name="configuration"> + /// HandBrakes config + /// </param> /// <returns> /// The <see cref="IHandBrakeInstance"/>. /// </returns> - public static IHandBrakeInstance GetScanInstance(int verbosity) + public static IHandBrakeInstance GetScanInstance(int verbosity, HBConfiguration configuration) { + if (!HandBrakeUtils.IsInitialised()) + { + throw new Exception("Please call Init before Using!"); + } + if (scanInstance != null) { scanInstance.Dispose(); @@ -95,7 +110,7 @@ namespace HandBrakeWPF.Instance } HandBrakeInstance newInstance = new HandBrakeInstance(); - newInstance.Initialize(verbosity); + newInstance.Initialize(verbosity, noHardware); scanInstance = newInstance; return scanInstance; @@ -115,6 +130,11 @@ namespace HandBrakeWPF.Instance /// </returns> public static IHandBrakeInstance GetPreviewInstance(int verbosity, HBConfiguration configuration) { + if (!HandBrakeUtils.IsInitialised()) + { + throw new Exception("Please call Init before Using!"); + } + if (previewInstance != null) { previewInstance.Dispose(); @@ -122,7 +142,7 @@ namespace HandBrakeWPF.Instance } HandBrakeInstance newInstance = new HandBrakeInstance(); - newInstance.Initialize(verbosity); + newInstance.Initialize(verbosity, noHardware); previewInstance = newInstance; HandBrakeUtils.SetDvdNav(!configuration.IsDvdNavDisabled); diff --git a/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs b/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs index 375dd2db1..e7c077c52 100644 --- a/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs +++ b/win/CS/HandBrakeWPF/Instance/RemoteInstance.cs @@ -98,7 +98,7 @@ namespace HandBrakeWPF.Instance return state; } - public void Initialize(int verbosity) + public void Initialize(int verbosity, bool noHardware) { this.StartServer(); } diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index 13ecd9daa..0a34c24c8 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -3051,7 +3051,7 @@ namespace HandBrakeWPF.Properties { } /// <summary> - /// Looks up a localized string similar to Hardware encoding support has been automatically disabled on your system due to an issue detected during hardware detection. Please make sure you are running up-to-date drivers for all graphics adaptors in this system. + /// Looks up a localized string similar to Hardware encoding support is currently disabled. Please make sure you are running up-to-date drivers for all graphics adaptors in this system. /// ///This will not impact any of the software encoders.. /// </summary> @@ -4591,6 +4591,15 @@ namespace HandBrakeWPF.Properties { } /// <summary> + /// Looks up a localized string similar to HandBrake's engine failed to initialise. This is often caused by out of date GPU drivers.\n Please update the GPU drivers for any onboard and discrete graphics your system has.. + /// </summary> + public static string Startup_InitFailed { + get { + return ResourceManager.GetString("Startup_InitFailed", resourceCulture); + } + } + + /// <summary> /// Looks up a localized string similar to Ready. /// </summary> public static string State_Ready { diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index 4546be660..4df1fbf68 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -1899,7 +1899,7 @@ This will not affect your current settings in the Subtitle tab.</value> <value>Show 'Add Selection to Queue' on the toolbar</value>
</data>
<data name="OptionsView_HardwareDetectFailed" xml:space="preserve">
- <value>Hardware encoding support has been automatically disabled on your system due to an issue detected during hardware detection. Please make sure you are running up-to-date drivers for all graphics adaptors in this system.
+ <value>Hardware encoding support is currently disabled. Please make sure you are running up-to-date drivers for all graphics adaptors in this system.
This will not impact any of the software encoders.</value>
</data>
@@ -1938,4 +1938,7 @@ Time Remaining: {5}, Elapsed: {6:d\:hh\:mm\:ss} {7}</value> <data name="Portable_IniFileError" xml:space="preserve">
<value>Portable Mode: Unable to read portable.ini. There may be an error in this file. Please retry using portable.ini.template as a guide.</value>
</data>
+ <data name="Startup_InitFailed" xml:space="preserve">
+ <value>HandBrake's engine failed to initialise. This is often caused by out of date GPU drivers.\n Please update the GPU drivers for any onboard and discrete graphics your system has.</value>
+ </data>
</root>
\ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs index de26ae87d..d545ee2ed 100644 --- a/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs +++ b/win/CS/HandBrakeWPF/Services/Scan/LibScan.cs @@ -128,7 +128,7 @@ namespace HandBrakeWPF.Services.Scan this.postScanOperation = postAction; // Create a new HandBrake Instance. - this.instance = HandBrakeInstanceManager.GetScanInstance(configuraiton.Verbosity); + this.instance = HandBrakeInstanceManager.GetScanInstance(configuraiton.Verbosity, configuraiton); this.instance.ScanProgress += this.InstanceScanProgress; this.instance.ScanCompleted += this.InstanceScanCompleted; diff --git a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs index 0b663f384..56e8d6d0d 100644 --- a/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/MainViewModel.cs @@ -117,8 +117,6 @@ namespace HandBrakeWPF.ViewModels IQueueViewModel queueViewModel, IMetaDataViewModel metaDataViewModel, INotifyIconService notifyIconService)
: base(userSettingService)
{
- HandBrakeUtils.RegisterLogger();
-
this.scanService = scanService;
this.presetService = presetService;
this.errorService = errorService;
@@ -185,8 +183,6 @@ namespace HandBrakeWPF.ViewModels // Setup Commands
this.QueueCommand = new QueueCommands(this.QueueViewModel);
- LogManager.Init();
- HandBrakeInstanceManager.Init();
}
#region View Model Properties
diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs index 1baeca994..374b1bcee 100644 --- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs @@ -1150,7 +1150,7 @@ namespace HandBrakeWPF.ViewModels }
}
- public bool IsHardwareFallbackMode => HandBrakeUtils.IsUsingNoHardwareFallback();
+ public bool IsHardwareFallbackMode => HandBrakeUtils.IsInitNoHardware();
#endregion
|