From 4e343a88bacfdc1d48d79442e81611bade6ab29a Mon Sep 17 00:00:00 2001 From: sr55 Date: Mon, 11 Feb 2019 14:25:46 +0000 Subject: WinGui: Utilise new hb_global_init_no_hardware when hb_global_init fails. The preferences Video tab now notes that hardware encoding options are disabled. --- win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs | 31 ++++++++++++++- .../HandBrake.Interop/Interop/HbLib/HbFunctions.cs | 3 ++ .../HandBrakeWPF/Properties/Resources.Designer.cs | 26 ++++++------- win/CS/HandBrakeWPF/Properties/Resources.de.resx | 45 +++++++++------------- win/CS/HandBrakeWPF/Properties/Resources.resx | 14 +++---- win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs | 3 ++ win/CS/HandBrakeWPF/Views/OptionsView.xaml | 12 +++++- 7 files changed, 79 insertions(+), 55 deletions(-) (limited to 'win') diff --git a/win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs b/win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs index acf4fa15f..7f36a406c 100644 --- a/win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs +++ b/win/CS/HandBrake.Interop/Interop/HandBrakeUtils.cs @@ -11,6 +11,8 @@ namespace HandBrake.Interop.Interop { using System; using System.Collections.Generic; + using System.Linq.Expressions; + using System.Runtime.CompilerServices; using System.Runtime.InteropServices; using HandBrake.Interop.Interop.EventArgs; @@ -40,6 +42,8 @@ namespace HandBrake.Interop.Interop /// private static bool globalInitialized; + private static bool failedWithHardware = false; + /// /// Fires when HandBrake has logged a message. /// @@ -50,6 +54,7 @@ namespace HandBrake.Interop.Interop /// public static event EventHandler ErrorLogged; + /// /// Initializes static members of the HandBrakeUtils class. /// @@ -57,9 +62,26 @@ namespace HandBrake.Interop.Interop { if (!globalInitialized) { - if (HBFunctions.hb_global_init() == -1) + try + { + + if (HBFunctions.hb_global_init() == -1) + { + throw new InvalidOperationException("HB global init failed."); + } + } + catch (Exception e) { - throw new InvalidOperationException("HB global init failed."); + failedWithHardware = true; + } + + // Try without Hardware support. Bad drivers can sometimes cause issues. + if (failedWithHardware) + { + if (HBFunctions.hb_global_init_no_hardware() == -1) + { + throw new InvalidOperationException("HB global init failed."); + } } globalInitialized = true; @@ -319,5 +341,10 @@ namespace HandBrake.Interop.Interop { ErrorLogged?.Invoke(null, new MessageLoggedEventArgs(message)); } + + public static bool IsUsingNoHardwareFallback() + { + return failedWithHardware; + } } } diff --git a/win/CS/HandBrake.Interop/Interop/HbLib/HbFunctions.cs b/win/CS/HandBrake.Interop/Interop/HbLib/HbFunctions.cs index c4c0cc006..689ceb937 100644 --- a/win/CS/HandBrake.Interop/Interop/HbLib/HbFunctions.cs +++ b/win/CS/HandBrake.Interop/Interop/HbLib/HbFunctions.cs @@ -27,6 +27,9 @@ namespace HandBrake.Interop.Interop.HbLib [DllImport("hb", EntryPoint = "hb_global_init", CallingConvention = CallingConvention.Cdecl)] public static extern int hb_global_init(); + [DllImport("hb", EntryPoint = "hb_global_init_no_hardware", CallingConvention = CallingConvention.Cdecl)] + public static extern int hb_global_init_no_hardware(); + /// Return Type: hb_handle_t* ///verbose: int ///update_check: int diff --git a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs index bebf83f6f..b9c05191f 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs +++ b/win/CS/HandBrakeWPF/Properties/Resources.Designer.cs @@ -3023,6 +3023,17 @@ namespace HandBrakeWPF.Properties { } } + /// + /// 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. + /// + ///This will not impact any of the software encoders.. + /// + public static string OptionsView_HardwareDetectFailed { + get { + return ResourceManager.GetString("OptionsView_HardwareDetectFailed", resourceCulture); + } + } + /// /// Looks up a localized string similar to The file format entered contained invalid characters. These have been removed. . /// @@ -5026,21 +5037,6 @@ namespace HandBrakeWPF.Properties { } } - /// - /// Looks up a localized string similar to QuickSync hardware not detected or enabled! - /// - ///In order to use the QuickSync encoder, you must: - /// - ///- Have a Intel CPU with HD Graphics and QuickSync support. 4th Generation Haswell or newer parts are recommended for best quality. - ///- Have the HD Graphics enabled. - ///- On older versions of windows before 8, a monitor connected to the HD Graphics or GPU Virtualisation software installed is also required.. - /// - public static string Video_QuickSyncNotAvailable { - get { - return ResourceManager.GetString("Video_QuickSyncNotAvailable", resourceCulture); - } - } - /// /// Looks up a localized string similar to Reduce decoder CPU usage. /// diff --git a/win/CS/HandBrakeWPF/Properties/Resources.de.resx b/win/CS/HandBrakeWPF/Properties/Resources.de.resx index 905e7b701..5b4581b73 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.de.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.de.resx @@ -59,46 +59,46 @@ : using a System.ComponentModel.TypeConverter : and then encoded with base64 encoding. --> - - + + - + - - - - + + + + - - + + - - + + - - - - + + + + - + - + @@ -170,15 +170,6 @@ Quellenmaximum: Kodiert nach Möglichkeit immer mit der Quellauflösung. Placebo Qualität | - - QuickSync-Hardware nicht erkannt oder aktiviert! - -Um den QuickSync-Kodierer verwenden zu können, muss: - -- Eine Intel CPU mit HD-Grafik und QuickSync-Unterstützung vorhanden sein. Haswell der vierten Generation oder neuer werden für beste Qualität empfohlen. -- HD-Grafik muss aktiviert sein. -- Bei älteren Versionen vor Windows 8 ist außerdem ein Monitor erforderlich, der an die installierte HD-Grafik- oder GPU-Virtualisierungssoftware angeschlossen ist. - Fehler @@ -1883,4 +1874,4 @@ Dies beeinflusst nicht die momentanen Einstellungen im Untertitel-Tab. Zeige 'Auswahl zur Warteschlange hinzufügen' in der Symbolleiste - + \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/Properties/Resources.resx b/win/CS/HandBrakeWPF/Properties/Resources.resx index 89ec0714c..1cf4cfc4e 100644 --- a/win/CS/HandBrakeWPF/Properties/Resources.resx +++ b/win/CS/HandBrakeWPF/Properties/Resources.resx @@ -184,15 +184,6 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.< Placebo Quality | - - QuickSync hardware not detected or enabled! - -In order to use the QuickSync encoder, you must: - -- Have a Intel CPU with HD Graphics and QuickSync support. 4th Generation Haswell or newer parts are recommended for best quality. -- Have the HD Graphics enabled. -- On older versions of windows before 8, a monitor connected to the HD Graphics or GPU Virtualisation software installed is also required. - Error @@ -1897,4 +1888,9 @@ This will not affect your current settings in the Subtitle tab. Show 'Add Selection to Queue' on the toolbar + + 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. + +This will not impact any of the software encoders. + \ No newline at end of file diff --git a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs index cf63d1daf..f4daf2e23 100644 --- a/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs +++ b/win/CS/HandBrakeWPF/ViewModels/OptionsViewModel.cs @@ -19,6 +19,7 @@ namespace HandBrakeWPF.ViewModels using Caliburn.Micro; + using HandBrake.Interop.Interop; using HandBrake.Interop.Model; using HandBrake.Interop.Utilities; @@ -1161,6 +1162,8 @@ namespace HandBrakeWPF.ViewModels } } + public bool IsHardwareFallbackMode => HandBrakeUtils.IsUsingNoHardwareFallback(); + #endregion #endregion diff --git a/win/CS/HandBrakeWPF/Views/OptionsView.xaml b/win/CS/HandBrakeWPF/Views/OptionsView.xaml index 8a04fddeb..31769f4a3 100644 --- a/win/CS/HandBrakeWPF/Views/OptionsView.xaml +++ b/win/CS/HandBrakeWPF/Views/OptionsView.xaml @@ -259,6 +259,16 @@ + + + + + + + + + + @@ -272,8 +282,6 @@ - -- cgit v1.2.3